2
我在我的應用程序中在Samsung Galaxy Note 2(Android 4.1.1)上顯示GIF時遇到問題。 Galaxy Nexus 7仿真器和其他的一切都很好。 這裏是我的源代碼:GIF不顯示在Samsung Galaxy Note 2
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
同樣的問題在這裏 – Sandy09