关于UI的TextView的及其子类一些方法

完成联系我功能(about us)--加入邮箱,手机号。

<TextView

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="邮件是191651196@qq.com,电话是13204508077"
android:autoLink="email|phone"/>



<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1">


//填写信息
<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="用户名:"
android:textSize="16sp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请填写登录账号"//隐藏文字,提示
android:selectAllOnFocus="true"/>//选择焦点输入
</TableRow>

 

//填写密码
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberPassword"/>

引申相关方法:

android:inputType="number"//输入数字,赋值后,输入法定性为数字

android:inputType="date"//输入日期,赋值后,输入法定性为日期

android:inputType="phone"//输入数据,赋值后,输入法定性为数字,输入格式字数控制


<!-- 设置文字颜色、大小,并使用阴影 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="测试文字"
android:shadowColor="#00f"
android:shadowDx="10.0"
android:shadowDy="8.0"
android:shadowRadius="3.0"
android:textColor="#f00"
android:textSize="18pt"/>


<!-- 设置中间省略,所有字母大写 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="我爱Java我aaaJava"
android:ellipsize="middle"//超范围中间省略
android:textAllCaps="true"/>//大小写


<!-- 设置字号为20pt,文本框结尾处绘制图片 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="我爱Java"
android:textSize="20pt"
android:drawableEnd="@drawable/cs"/>//插入图片

 

<?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 rg;
TextView show;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 获取界面上rg、show两个组件
rg = (RadioGroup) findViewById(R.id.rg);
show = (TextView) findViewById(R.id.show);
// 为RadioGroup组件的OnCheckedChange事件绑定事件监听器
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup group, int checkedId)
{
// 根据用户勾选的单选按钮来动态改变tip字符串的值
String tip = checkedId == R.id.male ?
"您的性别是男人": "您的性别是女人";
// 修改show组件中的文本
show.setText(tip);
}
});
}

//按键选择响应

 

posted @ 2015-09-08 10:41  小于同学  阅读(156)  评论(0编辑  收藏  举报