如何以编程方式在 Android 中翻转 ImageButton
我的应用程序中有 3 个 ImageButton。我想给它们添加一些漂亮的翻转效果。我想要的是,如果我点击一个按钮,那么就会有更多按钮,因为总共有 3 个按钮,所以应该翻转另一个按钮。如果有人看过会说话的汤姆应用程序,那么我希望在我的应用程序中拥有完全相同的功能。以下是会说话的汤姆应用程序的一些快照...
.
查看这两个图像。在图像中,您可以看到底部右侧有一个带有 FLIP 图标的按钮。单击该按钮后,底部左侧会出现另一个带有 TEA 和 SCRATCH 图标的按钮。那么当我点击 TEA & 翻页按钮时会发生什么? SCRATCH 按钮相应地翻转。
我想做同样的事情。我找到了关于视图、图像的教程,并且他们为此使用了单独的布局文件。我认为我的应用程序并非如此。如果有人对此有任何想法,请告诉我......
谢谢
I am having 3 ImageButton in my application. I wish to add some nice flipping effect on them. What i want is if i click on one button then there are more button as there is total 3, so the other button should be flipped. If any one has seen the Talking Tom app then i want the exactly same thing in my app. Here are some snapshot of that Talking tom app...
.
See the two images. In the images you can see that on the right hand side at the bottom there is a button with icon of FLIP. On click of that, there is another button with TEA and SCRATCH icon on the left side at bottom. SO what happens when i click on the flip button the TEA & SCRATCH button are flip accordingly.
I want to do the same thing..I found tutorials which are on View, Images and in that they used separate layout file for that. I think that's not the case in my app. If anyone has any idea about this please kindly let me know....
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 LevelListDrawable 来实现。在 XML 中,您可以使用
标签:然后,您可以通过为可绘制对象调用
setLevel()
或为ImageButton 调用
可绘制的。您可以通过翻转按钮的点击侦听器执行此操作。setImageLevel()
来控制级别正在显示的You can use a LevelListDrawable for that. In XML you can define it with a
<level-list>
tag:You can then control the level by calling
setLevel()
for the drawable orsetImageLevel()
for theImageButton
that is displaying the drawable. You would do this from the click listener for the flip button.也许为时已晚,也许不是,但只是为了通知我开发了一个新库 FlipView,其中包括基本功能翻转动画并扩展
ViewFlipper
。我的意思是一个完全可定制的库,您可以在其中将任何类型的视图和布局与您想要的任何类型的动画和形状(以及更多)交换,包括 Gmail 图像翻转。请看一下。
Maybe it's too late maybe not, but just to notify that I've developed a new library FlipView that includes basic flip animation and extends
ViewFlipper
. I mean a fully customizable library where you will be able to swap any kind of views and layouts with any kind of animation and shapes you desire (and much more), included the Gmail image flipping.Please have a look.