Android基础(一)基础控件

1.TextView:用来显示字符串的组件,在手机上就是显示一块文本的区域。

<TextView
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:text="Hello World! 你好,世界!Hello World! 你好,世界!Hello World! 你好,世界!"
        android:textSize="20sp"
        android:textColor="#f00"
        android:hint="这是提示语(text文本为空或没有的时候提示语才显示)"
        android:singleLine="true"
        android:background="#5500ffee"
        android:inputType="textPassword"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

知识点:
(1)表示宽度和高度的三种方式:
①match_parent 全部占满 ②wrap_content 自适应 ③100dp 具体的数值
(2)android:background="#5500ffee" 前两位表示透明度,后六位表示RGB颜色;背景也可以设置为图片
(3)android:singleLine=“true” 设置TextView显示一行,未显示部分打点(…)表示
(4)android:lines=“3” 设置TextView的行数
拓展:android:lines=“1”
android:ellipsize=“end”
以上两句可以实现与 android:singleLine=“true” 一样的效果
(5)android:inputType=“textPassword” 设置TextView为密码显示方式,将以点的形式代表字符
还有一种过时的表示方式:android:password=“true”
(6)android:text=“www.baidu.com”
android:autoLink=“web”
以上两句可以实现链接,点击可跳转
拓展:
在TextView 中设置autoLink 属性可以自动识别Web URL、电话号码、电子邮件地址、添加下划线改变字体颜色并实现点击事件,支持自动识别的类型:
android:autoLink=“web” 匹配Web URL。
android:autoLink=“phone” 匹配电话号码
android:autoLink=“email” 匹配电子邮件地址
android:autoLink=“map” 匹配地理位置
android:autoLink=“all” 匹配所有可用的模式
android:autoLink=“none” 不匹配任何类型
也可以类似这样的设

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值