如何翻转安卓按钮
我想在android扩展按钮中制作一个自定义按钮。当我点击按钮时,它会翻转 180 度并显示按钮的背面图像。这意味着该按钮将有两个图像。当点击它时,它会随着沿 y 轴旋转的动画而变化。
任何帮助表示赞赏。谢谢。
I wanna make a custom button in android extending buttons. When I will click on button, it will be flipped 180 degree and showed the back image of the buttons. That means the button will have two images. When it is clicked it will change with animation of rotation along y axis.
Any help are appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先为我可怜的恩感到抱歉。
然后...
你的布局 --> Flip.xml
您定义按钮或任何视图的第一侧和第二侧。
在您的活动中添加这部分
这部分代码启动翻转动画,最后一部分...
FlipAnimation.java
享受!
还有一件事,我之前在堆栈中找到了这段代码,但没有找到链接的答案。其他人编写了这段有用的代码。
at first sorry for my poor En.
and after that...
your layout --> flip.xml
you define your first and second side of your button or any view hear.
add this part in your activity
this part of code start the flip animation, and the last part ...
FlipAnimation.java
enjoy!
and one thing else, i found this code in stack before, but not found that answer to link. some one else wright this useful code.
https://github.com/stormzhang/FlipLayout -- 使用此库。它易于使用且适合您。
https://github.com/stormzhang/FlipLayout -- use this library. Its easy to use and for you.
我会使用 ScaleAnimation,它将按钮拉伸到 0 px 宽度,然后拉伸回 100%。当按钮具有最小宽度时,应更改背景和文本,以显示背面。
I would use a
ScaleAnimation
, which will stretch the button to 0 px width and then stretch it back to 100 %. When the button hast the minimal width, the background and text should be changed, in order to show the back side.