开发者

how to rotate a circular image button on its own axis in android app?

开发者 https://www.devze.com 2023-04-09 01:42 出处:网络
I have the following animation code : <?xml version=\"1.0\" encoding=\"utf-8\"?> <set xmlns:android=\"http://schemas.android.com/apk/res/android\">

I have the following animation code :

<?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="100"
android:duration="1000" />

</set>

//imageButton layout code

<ImageButton
android:id="@+id/anime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/start"
android:layout_centerHorizontal="true"
android:pa开发者_开发问答ddingLeft="10dip"
android:paddingTop="150dip"
android:paddingBottom="10dip"
android:paddingRight="10dip"
android:background="@null"
>
</ImageButton>

However, my circular image button is not rotating on its own axis. Rather, its following a circular path. Can anyone kindly help me out fix this animation ?

Thanks.


The pivot calculation in the animation is taking into account the padding of the ImageView. Since the padding is irregular (the top padding is different from the rest of the sides) the pivot of the animation is not aligned with the real center of your image.


the padding for the imagebutton should be uniform.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号