Android中自定义TextView的样式

Posted 西红柿里没有番茄

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android中自定义TextView的样式相关的知识,希望对你有一定的参考价值。

android自定义TextView的样式,改变背景颜色,边框粗细和颜色,角的弧度等

 

在res/drawable文件夹下新建一个dd.xml文件,建一个shap,在里面添加需要改变的内容

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


    <solid android:color="#ef0909"></solid>//设置背景色

    <stroke android:width="1px" android:color="#06ef21"></stroke>//设置边框属性


</shap

在布局文件中有控件引用刚才定义的xml文件

<TextView
        android:id="@+id/te"
        android:layout_width="300px"
        android:layout_height="100px"
        android:layout_marginTop="50px"
        android:background="@drawable/dd"
        />

 

以上是关于Android中自定义TextView的样式的主要内容,如果未能解决你的问题,请参考以下文章

Android中自定义Dialog样式

Android中自定义checkbox样式

Android中自定义样式与View的构造函数中的第三个参数defStyle的意义

Android之TextView的Span样式源代码剖析

具有自定义样式的TextView导致奇怪的膨胀异常

如何在 Android 中自定义 Spinner