TextView关于xml属性用法(待完善)

前端之家收集整理的这篇文章主要介绍了TextView关于xml属性用法(待完善)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

android textview行间距

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

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


@H_502_8@

textView 点击变变颜色@H_502_8@

java脚本@H_502_8@

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

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

<item android:state_pressed="true"@H_502_8@

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

<item android:state_focused="true"@H_502_8@

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

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

</selector>@H_502_8@

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); //设置按钮文字颜色
}@H_502_8@


@H_502_8@

xml配置@H_502_8@

@H_502_8@

<TextView@H_502_8@

android:id="@+id/tv_user_center_msg"@H_502_8@

android:layout_width="match_parent"@H_502_8@

android:layout_height="wrap_content"@H_502_8@

android:layout_marginTop="8dp"@H_502_8@

android:paddingBottom="8dp"@H_502_8@

android:paddingLeft="10dp"@H_502_8@

android:paddingTop="8dp"@H_502_8@

android:background="@drawable/btn_bg_white_blue_s"@H_502_8@

android:text="消息"@H_502_8@

android:textColor="@drawable/btn_text_black_white"@H_502_8@

android:textSize="18sp"@H_502_8@

android:clickable="true" />@H_502_8@

猜你在找的XML相关文章