2

アプリで Samsung Galaxy Note 2 (Android 4.1.1) の GIF を表示する際に問題があります。Galaxy Nexus 7エミュレーターなどではすべて問題ありません。ここに私のソースコードがあります:

public class ShouldersEx1 extends Activity {

View view;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    view = findViewById(R.id.image_arms_ex1);

    setContentView(R.layout.shoulders_ex1);
}

}

public class GIFView extends View {
private Movie movie;
private long moviestart;

public GIFView(Context context) throws IOException {
    super(context);
    movie = Movie.decodeStream(getResources().getAssets().open("barki1.gif"));
}

public GIFView(Context context, AttributeSet attrs) throws IOException {
    super(context, attrs);
    movie = Movie.decodeStream(getResources().getAssets().open("barki1.gif"));
}

public GIFView(Context context, AttributeSet attrs, int defStyle) throws IOException {
    super(context, attrs, defStyle);
    movie = Movie.decodeStream(getResources().getAssets().open("barki1.gif"));
}

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    long now = android.os.SystemClock.uptimeMillis();
    Paint p = new Paint();
    p.setAntiAlias(true);
    if (moviestart == 0)
        moviestart = now;
    int relTime;
    relTime = (int) ((now - moviestart) % movie.duration());
    movie.setTime(relTime);
    movie.draw(canvas, 0, 0);
    this.invalidate();
}

}

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<com.personaltrainer.utils.GIFView
    android:id="@+id/image_arms_ex1"
    android:layout_width="320dp"
    android:layout_height="240dp"
    android:layout_gravity="center"
    android:layout_marginLeft="30dp" >
</com.personaltrainer.utils.GIFView>

<TextView
    android:id="@+id/tresc_informacje"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/shoulders_ex1"
    android:textSize="20sp" 
    android:layout_margin="3dp"/>

何が間違っている可能性がありますか?すべての画面で次のエラーが表示されることに注意してください。

01-04 02:12:06.250: E/SpannableStringBuilder(29691): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
4

1 に答える 1

1

わかりました、私の知る限り、回避策はありません。公式に報告された問題は次のとおりです: http://code.google.com/p/android/issues/detail?id=3422

GIF は、Android エミュレータではすべての Android バージョンで動作しますが、Android 4.1 以降では動作しません。

私が見る可能な解決策:

  • Android 開発者がこの問題を解決するまでお待ちください

  • すべてのGIFを別々のフレームに分割し、200ミリ秒ごとに「手動で」変更するなど

于 2013-02-18T15:17:27.053 に答える