TextView关于xml属性用法待完善

android textview行间距

有两种方式:
android:linespacingExtra
设置行间距,如”6dip”。

android:linespacingMultiplier
设置行间距的倍数,如”2″。


textView 点击变变颜色

java脚本

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

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

<item android:state_pressed="true"

android:color="#ffff0000"/> <!-- pressed -->

<item android:state_focused="true"

android:color="#ff0000ff"/> <!-- focused -->

<item android:color="#ff000000"/> <!-- default -->

</selector>

Button button1=(Button)findViewById(R.id.Button01); //找到按钮Button01

ColorStateList color_state_list = null;
Resources resource=(Resources)getBaseContext().getResources();
color_state_list=(ColorStateList)resource.getColorStateList(R.color.color_state_list_button); //找到ColorStateList资源“color_state_list_button”
if(color_state_list!=null)
{
button1.setTextColor(color_state_list); //设置按钮文字颜色
}


xml配置

<TextView

android:id="@+id/tv_user_center_msg"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginTop="8dp"

android:paddingBottom="8dp"

android:paddingLeft="10dp"

android:paddingTop="8dp"

android:background="@drawable/btn_bg_white_blue_s"

android:text="消息"

android:textColor="@drawable/btn_text_black_white"

android:textSize="18sp"

android:clickable="true" />

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念