Android 给控件添加样式

Android中给控件添加样式分为两类:

其一:XML文件中:

        1、先在style.xml中定义样式:

1 <style name="text_style">
2       <item name="android:textStyle">bold</item>
3       <item name="android:textSize">18sp</item>
4 </style>

        2、在布局的XML文件中引用:

1 <TextView 
2         style="@style/text_style"
3         android:layout_width="wrap_content"
4         android:layout_height="wrap_content"
5 </TextView>

其二:Java文件中:

        TextView tv= new TextView(this);
        tv.setTextAppearance(this, R.style.text_style);
原文地址:https://www.cnblogs.com/zhangping/p/3645260.html