tableLayout 属性 ; 背景选择属性

  1. TableLayout的布局属性:android:stretchColumns="1" (设置TableLayout的所有行的第二列为扩展列,第一列后的其余空间由第二列补齐)

  2. 控件选中效果,xml文件设置:/res/drawable/widget_input.xml

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/widget_input_normal" android:state_enabled="false"></item> 
<item android:drawable="@drawable/widget_input_hover" android:state_focused="true"></item>
<item android:drawable="@drawable/widget_input_hover" android:state_selected="true"></item>
<item android:drawable="@drawable/widget_input_hover" android:state_pressed="true"></item>
<item android:drawable="@drawable/widget_input_normal"></item>

</selector>

android:drawable 放一个drawable资源
android:state_pressed 是否按下,如一个按钮触摸或者点击。
android:state_focused 是否取得焦点,比如用户选择了一个文本框。
android:state_hovered 光标是否悬停,通常与focused state相同,它是4.0的新特性
android:state_selected 被选中,它与focus state并不完全一样,如一个list view 被选中的时候,它里面的各个子组件可能通过方向键,被选中了。
android:state_checkable 组件是否能被check。如:RadioButton是可以被check的。
android:state_checked 被checked了,如:一个RadioButton可以被check了。
android:state_enabled 能够接受触摸或者点击事件
android:state_window_focused 应用程序是否在前台,当有通知栏被拉下来或者一个对话框弹出的时候应用程序就不在前台了

注意:如果有多个item,那么程序将自动从上到下进行匹配,最先匹配的将得到应用。(不是通过最佳匹配)
如果一个item没有任何的状态说明,那么它将可以被任何一个状态匹配。

本文出自 杀#嘻哈

文章地址 http://www.cnblogs.com/zouguo/p/3186256.html

原文地址:https://www.cnblogs.com/jidan/p/3189915.html