Button 类的层次关系如下:
java.lang.Object
↳ android.view.View
↳ android.widget.TextView
↳android.widget.Button
直接子类:
CompoundButton
间接子类:
CheckBox, RadioButton, ToggleButton
类方法
前面为方法,中间为解释,后面为方法的返回值
onKeyDown //当用户按键时,该方法调用 //Boolean
onKeyUp //当用户按键弹起后,该方法被调用 //Boolean
onKeyLongPress //当用户保持按键时,该方法被调用 //Boolean
onKeyMultiple //当用户多次调用时,该方法被调用 //Boolean
invalidateDrawable //刷新Drawable 对象 //void
scheduleDrawable //定义动画方案的下一帧 //void
unscheduleDrawable //取消scheduleDrawable 定义的动画方案 //void
onPreDraw //设置视图显示,列如在视图显示之前调整滚动轴的边界 //Boolean
sendAccessibilityEvent //发送事件类型指定的AccessibilityEvent。发送请求之前,需要检查Accessibility是否打开 //void
sendAccessibilityEventUnchecked //发送事件类型指定的
AccessibilityEvent。发送请求之前,不需要检查Accessibility是否打开 //void
setOnKeyListener //设置按键监听 //void
属性
android:layout_height //设置控件高度。可选值:fill_parent,warp_content,px
android:layout_width //设置控件宽度,可选值:fill_parent,warp_content,px
android:text //设置控件名称,可以是任意字符
android:layout_gravity //设置控件在布局中的位置,可选项:top,left,bottom,right,center_vertical,fill_vertica,fill_horizonal,center,fill 等
android:layout_weight //设置控件在布局中的比重,可选值:任意的数字
android:textColor //设置文字的颜色
android:bufferType //设置取得的文本类别,normal、spannable、editable
android:hint //设置文本为空是所显示的字符
android:textColorHighlight //设置文本被选中时,高亮显示的颜色
android:inputType //设置文本的类型,none,text,textWords 等