在Android中,旋转时钟和逆时针方向
我正在开发一个Android应用程序,其中有两个同心圆,文本位于中心。两个圆圈我都使用了drawable。我想逆时针旋转两个圆,即一个顺时针旋转,另一个逆时针旋转 下面给出了动画文件夹的代码以及活动代码和快照,以供解释 progress_left.xml在Android中,旋转时钟和逆时针方向,android,xml,android-layout,android-animation,Android,Xml,Android Layout,Android Animation,我正在开发一个Android应用程序,其中有两个同心圆,文本位于中心。两个圆圈我都使用了drawable。我想逆时针旋转两个圆,即一个顺时针旋转,另一个逆时针旋转 下面给出了动画文件夹的代码以及活动代码和快照,以供解释 progress_left.xml <?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" an
<?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" />
我不确定它是否会工作,但请尝试设置
android:toDegrees=“-360”
正在进行中\u right.xml。我不确定它是否会工作,但请尝试设置android:toDegrees=“-360”
正在进行中\u right.xml。只需在xml中添加一个图像视图并删除相对的布局移动。您的文本正在移动,因为您已将相对布局放置到动画中,并且文本位于布局中。更新的xml代码如下所示:
<?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_imageLayout"
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_imageLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/halfcircle" />
<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>
只需在xml中添加一个ImageView并删除相对布局移动。您的文本正在移动,因为您已将相对布局放置到动画中,并且文本位于布局中。更新的xml代码如下所示:
<?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_imageLayout"
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_imageLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/halfcircle" />
<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>
只需使用图像视图更改相对布局,并检查以下更新的代码:
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);
只需使用图像视图更改相对布局,并检查以下更新代码:
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);
什么是问题?什么是问题?这对我有用。旋转现在是逆时针的,这对我很有用。旋转现在是逆时针的,thanx
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);