I have to rotate a button (or the text inside, it's the same) by random degree by coding. Is there any button.setRotate(x) in API level lower then 11??
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Ok, had a look and the answer is: It's complicated.
You can rotate the button using the old animation framework, e.g. like this:
The problem here is that the button looks rotated, but can't be clicked correctly. The coordinates that trigger the click event are the ones at the area the button had before beeing rotated.
Since this is not a very good solution, your best bet is probably to write a custom view that extends the Button class and rotate the buttons canvas in
onDraw()
. You also have to overrideonMeasure()
in this case. See Custom Components for a introduction what to do.Apart from that you can try to intercept click events from the buttons parent layout and trigger the appropriate event when the click happened within the buttons current coordinates. This is somewhat "hacky" though.