本文将以TextView为例,介绍TextView的基本属性及其他属性产生的各种效果。
效果展示:
1、TextView基本属性
<TextView
android:id="@+id/tv_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tv_1"
android:textColor="#F99730"
android:textSize="26sp"/>
text 中的内容:
<resources>
<string name="app_name">helloworld2</string>
<string name="tv_1">你在干什么</string>
</resources>
2、文字省略形式(ellipsize属性)
效果:
ellipsize属性可以将文字显示的形式改为省略号的形式(前提是要强制设置一下width的长度,不然文字可以显示下就不会有该效果了)
2.1、将省略号显示在文字后面:(效果1)
ellipsize设为end
<TextView
android:id="@+id/tv_2"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="@string/tv_1"
android:textColor="#F99730"
android:textSize="26sp"
android:maxLines="1"
android:ellipsize="end"
android:layout_marginTop="20dp"/