android之【部分控件】

button  And ImageButton
<!-- 普通文字按钮 -->	
<Button
	android: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"/>
 
 


<!-- 按下时显示不同图片的按钮 -->
<ImageButton
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:src="@drawable/button_selector"
	android:background="#000000"
/>
<!-- 带文字的图片按钮-->
<Button
	android: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  -->
	<TextView
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content" 
	android:text="我爱Java"
	android:textSize="20pt"
	/>
	<!-- 设置中间省略 -->
	<TextView
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content"
	android:singleLine="true" 
	android:text="我爱Java我爱Java我爱Java我爱Java我爱Java我aaaJava"
	android:ellipsize="middle"
	/>
	<!-- 对邮件增加链接 -->
	<TextView
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content"
	android:singleLine="true" 
	android:text="测试[email protected]内容"
	android:autoLink="email"
	/>
	<!-- 设置文字颜色 、大小,并使用阴影 -->
	<TextView
	android: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" 
	/>
<!-- 定义数字时钟 -->
<DigitalClock
	android:layout_width="wrap_content" 
	android:layout_height="wrap_content" 
	android:textSize="14pt"
	/>	



你可能感兴趣的:(android)