Android7.0中文API---ImageButton
来源:互联网 发布:linux 跨机器拷贝文件 编辑:程序博客网 时间:2024/05/29 17:32
完整内容请查看http://www.zhdoc.net/android/reference/android/widget/ImageButton.html
ImageButton
public class ImageButton
extendsImageView
Displays a button with an image (instead of text) that can be pressed or clicked by the user. By default, an ImageButton looks like a regularButton
, with the standard button background that changes color during different button states. The image on the surface of the button is defined either by theandroid:src
attribute in the <ImageButton>
XML element or by thesetImageResource(int)
method.
在按钮上显示图像(而不是文本),它可以被用户按下或点击。默认情况下,一个ImageButton看起来就像一个普通Button
,标准按钮的背景在不同的按钮状态下,会改变颜色。按钮上的图片,由<ImageButton>
XML元素中android:src
属性来定义,或由setImageResource(int)
方法来设置。
To remove the standard button background image, define your own background image or set the background color to be transparent.
删除标准按钮上的背景图片,定义你自己的背景图片或者设置背景颜色为透明。
To indicate the different button states (focused, selected, etc.), you can define a different image for each state. E.g., a blue image by default, an orange one for when focused, and a yellow one for when pressed. An easy way to do this is with an XML drawable "selector." For example:
指明不同的按钮状态(focused,selected,等),你可以为每个状态定义不同的图片。例如,默认是一个蓝色的图片,当focused状态时,则为一个橙色的图片,而当pressed状态时,则为一个黄色的图片。一种简单的方法是使用一个XML drawable的selector”。例如:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/button_pressed" /> <!-- pressed --> <item android:state_focused="true" android:drawable="@drawable/button_focused" /> <!-- focused --> <item android:drawable="@drawable/button_normal" /> <!-- default --> </selector>
Save the XML file in your project res/drawable/
folder and then reference it as a drawable for the source of your ImageButton (in theandroid:src
attribute). Android will automatically change the image based on the state of the button and the corresponding images defined in the XML.
将XML文件保存到你的项目中的res/drawable/
路径下,然后作为你的ImageButton的源的一个drawable来引用(在android:src
属性中)。Android将根据按钮的状态和XML中定义的相应的图像,自动更改按钮的图像。
The order of the <item>
elements is important because they are evaluated in order. This is why the "normal" button image comes last, because it will only be applied afterandroid:state_pressed
andandroid:state_focused
have both evaluated false.<item>
元素中的顺序非常重要,因为它们是按顺序进行计算的。这就是为什么“normal”的按钮图片是放置最后,因为它只会在android:state_pressed
和android:state_focused
都被评估为false时,才会使用。
See the Buttons guide.
请参考Buttons。
XML attributes
XML属性
See Button Attributes
,View Attributes
参考Button Attributes
View Attributes
摘要
继承XML属性
android.widget.ImageView
android.view.View
继承常量
android.view.View
继承字段
android.view.View
Public构造方法
ImageButton(Context context)
ImageButton(Context context, AttributeSet attrs)
ImageButton(Context context, AttributeSet attrs, int defStyleAttr)
ImageButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public方法
CharSequence
getAccessibilityClassName()
Return the class name of this object to be used for accessibility purposes.
返回此对象的类名,用于辅助功能目的。
PointerIcon
onResolvePointerIcon(MotionEvent event, int pointerIndex)
Returns the pointer icon for the motion event, or null if it doesn't specify the icon.
返回MotionEvent的指针图标,如果没有指定图标,则为null。
保护方法
boolean
onSetAlpha(int alpha)
Invoked if there is a Transform that involves alpha.
如果存在涉及alpha的转换, 则调用此方法。
继承方法
android.widget.ImageView
android.view.View
java.lang.Object
android.graphics.drawable.Drawable.Callback
android.view.KeyEvent.Callback
android.view.accessibility.AccessibilityEventSource
Public构造方法
ImageButton
ImageButton (Context context)
context
Context
ImageButton
ImageButton (Context context, AttributeSet attrs)
context
Context
attrs
AttributeSet
ImageButton
ImageButton (Context context, AttributeSet attrs, int defStyleAttr)
context
Context
attrs
AttributeSet
defStyleAttr
int
ImageButton
ImageButton (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
context
Context
attrs
AttributeSet
defStyleAttr
int
defStyleRes
int
Public方法
getAccessibilityClassName
CharSequence getAccessibilityClassName ()
Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName
.
返回此对象的类名,用于辅助功能目的。如果它们实现了一些在辅助服务中被视为视图的一个完全的新类,而与它所派生的类无关,则子类应该仅重载此方法。这个值在AccessibilityNodeInfo.setClassName
中被填充。
CharSequence
onResolvePointerIcon
完整内容请查看http://www.zhdoc.net/android/reference/android/widget/ImageButton.html
- Android7.0中文API---ImageButton
- Android7.0 中文API -- ZoomButton
- Android7.0中文API --- ImageView
- Android7.0中文API -- ListView
- android7.0中文API -- LinearLayout
- Android7.0中文API -- TableLayout
- Android7.0中文API -- TableRow
- Android7.0中文API -- ZoomControls
- Android7.0中文API -- TabWidget
- Android7.0中文API -- ActionMenuView
- Android7.0中文API -- RadioGroup
- Android7.0中文API -- SearchView
- Android7.0中文API -- SeekBar
- Android7.0中文API -- ProgressBar
- Android7.0中文API --- AbsSeekBar
- Android7.0中文API -- RatingBar
- Android7.0中文API -- Spinner
- Android7.0中文API -- AbsSpinner
- Fragment中Toast报空指针异常
- kvm理解
- 2.3 ls命令
- POJ 1781 In Danger 笔记
- 300. Longest Increasing Subsequence
- Android7.0中文API---ImageButton
- 浅谈Android 触摸事件分发机制
- 使用python 3.6.0
- 《嵌入式linux应用程序开发详解》核心笔记
- C语言指针导学(1)——指针到底是什么
- 2.4 文件类型+2.5 alias
- springmvc源码2 这篇写的有问题 会重新写
- 【6月】闲聊
- 死锁