2015-11-08 111 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