2.3.1TextView控件

简介

TextView控件是一个文本框,经常使用的一个控件。

常用属性

|属性|含义|属性值
|-|-|
|android:text|显示文本|
|android:textColor|文本颜色|"#000000"采用六位十六进制的RGB颜色模式|
|android:textSize|文本大小|通常使用sp作为字体的单位|
|android:textStyle|文本样式|bold表示粗体,italic表示斜体,bolditalic(粗斜体)|
|android:gravity|文本在控件中的位置|可选left,right,top,bottom,center等|
|android:maxLength|文本的长度,超出不显示|
|android:drawableLeft|在文本左侧显示图片|
|android:drawableRight|在文本右侧显示图片|
|android:drawableTop|在文本上面显示图片|
|android:drawableBottom|在文本下面显示图片|

例如:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
    <TextView
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:text="hello world"
        android:textColor="#FF0000"
        android:textSize="20sp"
        android:textStyle="bold"
        android:gravity="bottom"
        android:maxLength="10"
        android:drawableLeft="@mipmapic_launcher_round"
        />

</LinearLayout>

小技巧

属性的叠加

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容