Ahs*_*san 6 animation android imagebutton
我对Android中的动画(以及其他任何东西)都很陌生.有没有办法动画ImageButton?我只是想有时旋转按钮.就这样.有帮助吗?
谢谢.
Nir*_*tel 10
试试这段代码.
rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="0"
android:duration="1000" />
</set>
Run Code Online (Sandbox Code Playgroud)
在java文件中
ImageButton imgbt = (ImageButton)findViewById(R.id.your_id);
Animation ranim = (Animation)AnimationUtils.loadAnimation(context, R.anim.rotate);
imgbt.setAnimation(ranim);
Run Code Online (Sandbox Code Playgroud)
rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:startOffset="0"
android:toDegrees="360" />
Run Code Online (Sandbox Code Playgroud)
Java代码:
RotateAnimation rotateAnimation = (RotateAnimation) AnimationUtils.loadAnimation(context,R.anim.rotate);
view.startAnimation(rotateAnimation);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12993 次 |
| 最近记录: |