Usm*_*han 1 xml android android-animation android-layout
我正在开发一个Android应用程序,其中我有两个同心圆,文本位于中心.我用过两个圆圈的drawable.我想将两个圆圈逆时针旋转,即一个顺时针旋转,另一个顺时针旋转.
我的代码在下面给出了活动代码中的动画文件夹和快照以供解释.

progress_left.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="360" />
Run Code Online (Sandbox Code Playgroud)
progress_right.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="0" />
Run Code Online (Sandbox Code Playgroud)
我的活动布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/red_theme"
android:orientation="vertical" >
<Button
android:id="@+id/btnStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="28dp"
android:text="Start" />
<Button
android:id="@+id/btnStop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="67dp"
android:text="Stop" />
<RelativeLayout
android:id="@+id/main_imageLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/halfcircle"
android:orientation="horizontal"
android:padding="5dp" >
<ImageView
android:id="@+id/main_imageRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/halfcircle" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="MUry"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
</RelativeLayout>
<TextView
android:id="@+id/textViewTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/Beige"
android:layout_above="@+id/btnStop"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:textSize="100sp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的活动代码
Animation animRight = AnimationUtils.loadAnimation(this,
R.anim.progress_right);
animRight.setDuration(1000);
mImageRight.startAnimation(animRight);
Animation animLeft = AnimationUtils.loadAnimation(this,
R.anim.progress_left);
animLeft.setDuration(1000);
mLLLeft.startAnimation(animLeft);
Run Code Online (Sandbox Code Playgroud)
小智 5
只需使用"图像"视图更改相对布局,然后检查以下更新的代码:
private ImageView mImageLeft, mImageRight, mImageProfile;
private ImageView mLLLeft;
mLLLeft = (ImageView) findViewById(R.id.main_imageLeft1);
mImageRight = (ImageView) findViewById(R.id.main_imageRight);
Animation animRight = AnimationUtils.loadAnimation(this,
R.anim.progress_right);
animRight.setDuration(1000);
mImageRight.startAnimation(animRight);
Animation animLeft = AnimationUtils.loadAnimation(this,R.anim.progress_left);
animLeft.setDuration(1000);
mLLLeft.startAnimation(animLeft);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2424 次 |
| 最近记录: |