我是 android 开发的新手,谁能告诉我如何将整个按钮连同文本和按钮矩形一起旋转 45 度。我想永久旋转,我想点击监听器。
最佳答案
你需要为此使用动画。
在您的/res/anim/中,您必须使用以下内容创建一个 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="45"
android:pivotX="50%"
android:pivotY="50%"
android:duration="0"
android:startOffset="0"
/>
在您的 Activity 中:
RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this, R.anim.YOUR_ANIM);
ranim.setFillAfter(true);
YourButton.setAnimation(ranim);
除此之外, hive 前的对角线旋转(又名 45 度)似乎存在一些问题..
关于android - 如何倾斜按钮及其文本......?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8048655/