gpt4 book ai didi

java - 如何从中心位置旋转 ImageView

转载 作者:太空狗 更新时间:2023-10-29 16:18:55 25 4
gpt4 key购买 nike

我想将我的 Imageview 从它的中心位置移开。 imageview 的一侧在上面,之后 imageview 的另一侧应该下降imageview 的中心总是固定的。如何做到这一点我的代码是

imageView= (ImageView) findViewById(R.id.imageView1);

imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
RotateAnimation animation = new RotateAnimation(80, 90, imageView.getWidth() / 2, 400);

animation.setDuration(400); // you may set another duration
animation.setFillAfter(true);
imageView.startAnimation(animation);

}
});
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="86dp"
android:src="@drawable/top_pati" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageView1"
android:layout_below="@+id/imageView1"
android:src="@drawable/top_pativertical" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/imageView1"
android:layout_below="@+id/imageView1"
android:src="@drawable/top_pativertical" />

喜欢秤类型我做这份工作的动画类型...

最佳答案

使用此代码

RotateAnimation anim = new RotateAnimation(0, 45, Animation.RELATIVE_TO_SELF,
0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

anim.setInterpolator(new LinearInterpolator());
anim.setDuration(500);
anim.setFillEnabled(true);
anim.setFillAfter(true);

image.startAnimation(anim)

关于java - 如何从中心位置旋转 ImageView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20608073/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com