0
我正在嘗試使用背景圖像對ImageView進行動畫處理。動畫在第一次加載時很好,但之後會變得遲緩並且不會出現動畫。Android內置的動畫不正確
文件---- main.xml中
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="31dp"
/>
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/editText1"
android:layout_marginRight="30dp"
android:layout_marginTop="52dp"
android:text="Click me" />
文件---- TutorialActivity.java
private isClicked = 0;
private Animation animUp;
private Animation animDown;
animUp = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
animDown = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
animUp.setDuration(500);
animDown.setDuration(500);
Button clickButton = (Button) findViewById(R.id.button2);
clickButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v)
{
if(isClicked == 0)
{
menu.setVisibility(View.VISIBLE);
menu.setAnimation(animUp);
isClicked = 1;
}
else
{
menu.setAnimation(animDown);
menu.setVisibility(View.GONE);
isClicked = 0;
}
}