Buttons 示例介绍了定义Button,ToggleButton的基本方法。本例在/res/layout/buttons_1.xml 定义如下:

<!– Regular sized buttons –>
<Button android:id=”@+id/button_normal”
android:text=”@string/buttons_1_normal”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” />

<!– Small buttons –>
<Button android:id=”@+id/button_small”
style=”?android:attr/buttonStyleSmall”
android:text=”@string/buttons_1_small”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” />

<ToggleButton android:id=”@+id/button_toggle”
android:text=”@string/buttons_1_toggle”
android:textOn=”Open”
android:textOff=”Close”

android:layout_width=”wrap_content”
android:layout_height=”wrap_content” />

定义button 不指定任何风格时,Android以正常大小显示Button,

风格 ?android:attr/buttonStyleSmall 以紧凑风格显示Button。

在引用Style 属性值时, 使用“?” 而非”@” 来指定所需风格属性,格式如下:

?[<package_name>:][<resource_type>/]<resource_name>

其中resource_type部分可选,因此 本例也可以使用如下定义:

style=”?android:buttonStyleSmall”

ToggleButton 使用button 形式定义两种状态,比如Open,Close。缺省文本为ON, OFF, 可以使用属性textOn,textOff 重新定义文字。

更多相关文章

  1. Android(安卓)ApiDemos示例解析(5):App->Activity->Custom Title
  2. 详解Android(安卓)TableLayout中stretchColumns、shrinkColumns
  3. Android(安卓)状态栏透明的一些小结
  4. 解决:android:editable is deprecated: Use an to make it edita
  5. android中ImageView的ScaleType属性
  6. Android控件属性大全
  7. Android(安卓)android:scaleType属性 图片按比例缩放
  8. android animation 简单介绍
  9. GestureOverlayView属性

随机推荐

  1. [转]Android(安卓)应用开发中国大学生挑
  2. Android(安卓)Q 不叫 Q,正式命名为 Androi
  3. android shape 使用小结
  4. Android开发注意点小记
  5. 安卓布局:线性布局(Linearlayout)和相对布
  6. Android 4.0 SDK的离线方式安装
  7. 解决ListView,GridView,Gallery的Adapter
  8. Android数据库SQLite使用详解一 : SQLite
  9. android http://dl-ssl.google.com/andro
  10. Android中的Environment.getExternalStor