什么是使用图像按钮呢? [英] what is use of image button?

查看:137
本文介绍了什么是使用图像按钮呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid应用程序的开发。
我想问一下在Android中的编程使用图像按钮时,简单的按钮也可以使用按钮来添加图像。我们怎样才能产生点击图片按钮的事件?

I'm new to Android application development. I would like to ask the use of image button in Android programming when simple button can also add the image with the button. How can we generate click event of image button?

推荐答案

如果你会看的API中的按钮你会看到它有一个从查看继承的方法称为setOnClickListener。由于的ImageButton也是一个视图,也可以调用它的方法相同。

If you will look in the API for Button you will see that it has a method called setOnClickListener that is inherited from View. Since ImageButton is also a view, you can also call the same method for it.

这是我看到的一个按钮来使用图像的唯一方法是通过使用机器人:在XML的背景。这仅用于设置什么是显示一个按钮上的文字后面。当你想只使用图像作为其定义功能的按键,你应该使用的ImageButton。如果你最终想看到的只是图像,并有明显的无按钮背景的一部分,您可以设置的android:按钮背景使用透明的可绘制

The only way that I see to use an image in a Button is by using android:background in the XML. This is only used for setting what's shown behind the text of a button. You should use ImageButton when you want to make a button that only uses the image as its defining feature. If you end up wanting to only see the image and have no part of the button background visible, you can set android:background on the button to use an invisible Drawable.

这篇关于什么是使用图像按钮呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆