textEdit可以添加背景图片、渐变色、文字颜色、大小等等

textEdit

 

 

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
    >
        <!--设置字号为20pt,在文本末尾绘制图片-->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Hello World!"
            android:textSize="20pt"
            android:drawableEnd="@mipmap/ic_launcher"
            android:drawableRight="@mipmap/ic_launcher"
        />
        <!--设置中间省略,所有字母大写-->
        <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:ellipsize="middle"
                android:textAllCaps="true"
                android:text="学习Android学习Android学习Android学习Android学习Android学习Android学习Android"
        />
        <!--设置文字颜色、大小、使用阴影-->
        <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="测试文字"
                android:shadowColor="#00f"
                android:shadowDx="10.0"
                android:shadowDy="8.0"
                android:shadowRadius="3.0"
                android:textColor="#ff0"
                android:textSize="18pt"
        />
        <!--设置可勾选文本-->
        <CheckedTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="可勾选的文本"
                android:checkMark="@drawable/ok"
        />
        <!--指定背景-->
        <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="带边框的文本"
                android:textSize="24pt"
                android:background="@drawable/bg_border"
        />
        <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="圆角边框,渐变背景"
                android:textSize="24pt"
                android:background="@drawable/bg_border2"
        />
    </LinearLayout>
</ScrollView>
activaty_main.xml

相关文章:

  • 2021-07-02
  • 2022-12-23
  • 2021-07-05
  • 2022-01-28
  • 2022-03-09
  • 2022-12-23
  • 2022-01-10
  • 2021-08-13
猜你喜欢
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
相关资源
相似解决方案