2015-11-08 185 views
2

我將圖像設置爲FloatingActionButton。現在,當點擊fab時,背景按鈕將開始旋轉。旋轉按鈕的背景圖像

我使用此代碼

imgview =(ImageView的)findViewById(R.id.rotate)做圖像旋轉;

anim = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 
     .51111112f, Animation.RELATIVE_TO_SELF, 0.5f); 
anim.setInterpolator(new LinearInterpolator()); 
anim.setRepeatCount(Animation.INFINITE); 
anim.setDuration(1500); 
imgview.startAnimation(anim); 

但不能旋轉fab背景圖像。

任何人都可以幫忙嗎?

回答

0

我認爲你正在使用android:background=""使用本android:src="" 這裏的例子

<android.support.design.widget.FloatingActionButton android:id="@+id/fab" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" 
     android:src="@android:drawable/ic_dialog_email" /> 

,並設置爲clicklistener晶圓廠按鈕

+0

是的,我這樣做了'fab'。但我的問題是如何在單擊'fab'時旋轉圖像? – Sudarshan