与Android旋转按钮:旋转XML [英] rotate a button with android:rotation xml
问题描述
我想一个按钮(作为图片)只是UI顺时针旋转。我不想旋转按钮的onClick。就在xml文件旋转就足够了。机器人:旋转不会为我工作
我的code是
<按钮
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=新按钮
机器人:背景=@绘制/按钮
机器人:旋转= - 90
机器人:ID =@ + ID /按钮
机器人:layout_gravity =右侧|左
机器人:layout_centerVertical =真
机器人:layout_centerHorizontal =真/>
<?XML版本=1.0编码=UTF-8&GT?;
<设置的xmlns:机器人=http://schemas.android.com/apk/res/android>
<旋转机器人:fromDegrees =0
机器人:toDegrees =360
机器人:pivotX =50%
机器人:pivotY =50%
机器人:时间=600
机器人:REPEATMODE =重启
安卓的repeatCount =无限
机器人:插值=@机器人:动画/ cycle_interpolator/>< /集>
时钟明智的 - 用积极的toDegrees值
反时针 - 使用负的toDegrees值
I want a button(as an image) to rotate clockwise just for UI. I dont want to rotate the button onClick. Just rotate in xml file is enough. android:rotation does not work for me.
my code is
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:background="@drawable/button"
android:rotation="-90"
android:id="@+id/button"
android:layout_gravity="right|left"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<?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:duration="600"
android:repeatMode="restart"
android:repeatCount="infinite"
android:interpolator="@android:anim/cycle_interpolator"/>
</set>
Clock wise – use positive toDegrees value
Anti clock wise – use negative toDegrees value
这篇关于与Android旋转按钮:旋转XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!