android之【部分控件】
16lz
2021-12-04
button And ImageButton
<!-- 普通文字按钮 --><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/red"android:text="普通按钮"android:textSize="10pt"/><!-- 普通图片按钮 --><pre name="code" class="html">
<ImageButtonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/blue"android:background="#000000"/>
<!-- 按下时显示不同图片的按钮 --><ImageButtonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/button_selector"android:background="#000000"/><!-- 带文字的图片按钮--><Buttonandroid:id="@+id/test"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/button_selector"android:text="带文字的图片按钮"/>button_selector.xml
<?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/red"/><!-- 指定按钮松开时的图片 --><item android:state_pressed="false"android:drawable="@drawable/purple"/></selector>
单选框
<!-- 定义一组单选框 --><RadioGroup android:orientation="horizontal"android:layout_gravity="center_horizontal"><!-- 定义两个单选框 --><RadioButton android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="男"/><RadioButton android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="女"/></RadioGroup>
定义复选框
<!-- 定义三个复选框 --><CheckBox android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="红色"android:checked="true"/><CheckBox android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="蓝色"/><CheckBox android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="绿色"/>
TextView
<!-- 设置字体为20pt --><TextViewandroid:layout_width="fill_parent" android:layout_height="wrap_content" android:text="我爱Java"android:textSize="20pt"/><!-- 设置中间省略 --><TextViewandroid:layout_width="fill_parent" android:layout_height="wrap_content"android:singleLine="true" android:text="我爱Java我爱Java我爱Java我爱Java我爱Java我aaaJava"android:ellipsize="middle"/><!-- 对邮件增加链接 --><TextViewandroid:layout_width="fill_parent" android:layout_height="wrap_content"android:singleLine="true" android:text="测试kongyeeku@163.com内容"android:autoLink="email"/><!-- 设置文字颜色 、大小,并使用阴影 --><TextViewandroid:layout_width="fill_parent" android:layout_height="wrap_content" android:text="测试文字"android:shadowColor="#0000ff"android:shadowDx="15.0"android:shadowDy="20.0"android:shadowRadius="45.0"android:textColor="#ff0000"android:textSize="25pt"/><!-- 测试密码框 --><TextView android:id="@+id/passwd"android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello"android:password="true"/>
时钟
<!-- 定义模拟时钟 --><AnalogClock android:layout_width="wrap_content" android:layout_height="wrap_content" /><!-- 定义数字时钟 --><DigitalClockandroid:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="14pt"/>
更多相关文章
- Android(安卓)Studio代码笔记09.自定义视图
- android内部类
- Android在Button按钮上同时显示文字和图片
- 自定义Android(安卓)Toasts风格
- android 实用工具类-对话框
- android 文字滚动动画
- Android弹球小游戏
- android 笔记 --- 自定义Android主题风格theme.xml方法
- Android中的style&themes