Kev*_*gan 12
您可以手动设置它们的动画,例如游戏精灵.另一种选择是反对旋转动画:
rotate_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:toDegrees="0"
android:fromDegrees="359"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"
android:repeatCount="infinite"
android:interpolator="@android:anim/linear_interpolator"
/>
</set>
Run Code Online (Sandbox Code Playgroud)
rotate_right.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:toDegrees="359"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"
android:repeatCount="infinite"
android:interpolator="@anim/lin"
/>
</set>
Run Code Online (Sandbox Code Playgroud)
布局xml文件(只是顶部和底部的文本框.你必须自己实现4个角;)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<FrameLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/outer"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/top"
android:text="Top"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/bottom"
android:text="Bottom"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在您的活动中:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.[yourlayout]);
findViewById(R.id.outer).startAnimation(AnimationUtils.loadAnimation(this,R.anim.rotate_left));
findViewById(R.id.top).startAnimation(AnimationUtils.loadAnimation(this,R.anim.rotate_right));
findViewById(R.id.bottom).startAnimation(AnimationUtils.loadAnimation(this,R.anim.rotate_right));
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我不能让旋转正确使用线性插值器.它不断加速/减速.可能必须在代码中这样做.
| 归档时间: |
|
| 查看次数: |
7260 次 |
| 最近记录: |