Android 在xml和java代码中设置控件的style

版权声明:本文为程序园中猿原创文章,转载请注明出处 https://blog.csdn.net/yinxing2008/article/details/85163135
  1. 增加style定义
<style name="myTextStyle">
    <item name="android:textStyle">bold</item>
    <item name="android:textSize">16sp</item>
</style>
  1. XML文件中使用
<TextView 
	style="@style/text_style"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
</TextView>
  1. Java代码中使用(API需要大于等于23)
TextView.setTextAppearance(this, R.style.myTextStyle);

安卓开发技术分享: https://blog.csdn.net/yinxing2008/article/details/84555061

猜你喜欢

转载自blog.csdn.net/yinxing2008/article/details/85163135
今日推荐