0
有沒有一種方法可以爲相對佈局改變背景圖像的動畫效果?謝謝。改變背景時動畫RelativeLayout
有沒有一種方法可以爲相對佈局改變背景圖像的動畫效果?謝謝。改變背景時動畫RelativeLayout
我找到了工作,圍繞它,, :)
<ImageView
android:id="@+id/giftAppBgImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/giftApp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/giftApp"
android:layout_below="@+id/TopborderBGImage"
android:clickable="true"
android:scaleType="fitXY"
android:src="@drawable/cell_bg" />
<RelativeLayout
android:id="@+id/giftApp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/TopborderBGImage"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:src="@drawable/gift_icon" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView1"
android:text="Gift this app"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/titleMiddleColor"
android:textStyle="bold" />
<TextView
android:id="@+id/moreShaderCell1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:text="Continuous reward for you, InshaAllah!"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/titleMiddleColor" />
</RelativeLayout>
setOnClickListener
findViewById(R.id.giftAppBgImage).setOnClickListener(this);
@Override
public void onClick(final View v) {
// TODO AK-generated method stub
showLog("catch onClick event!" + v.getClass().getName());
if (v instanceof ImageView) {
((ImageView) v).setImageResource(R.drawable.cell_bg_hover);
Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.more_animation);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
// TODO AK-generated method stub
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO AK-generated method stub
}
@Override
public void onAnimationEnd(Animation arg0) {
// TODO AK-generated method stub
((ImageView) v).setImageResource(R.drawable.cell_bg);
}
});
v.startAnimation(anim);
}
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:fillAfter="true"
android:duration="500"/>
</set>
你想要哪種類型的動畫? – 2012-08-06 04:07:44
你可以查看這個鏈接。 http://stackoverflow.com/questions/4503039/layout-animation-not-working-on-first-run – 2012-08-06 04:08:52
或者這個也對動畫的因素有用。 http://stackoverflow.com/questions/8933224/relativelayout-causes-animation-not-to-work – 2012-08-06 04:09:55