1、UI组件整体介绍
Android系统为我们提供了丰富的可视化用户界面组件,包括菜单、对话框、按钮、下拉列表等。Android系统中的所有UI类都是建立在View和ViewGroup这两个类的基础上,所有的View的子类称为widget,所有的ViewGroup的子类称为Layout。
2、组件的简单分类
3、TextView(文本视图)
显示文本的组件,类似于html中的label标签
基本语句
<!--
layout_width
layout_height
相对设置
wrap_content 相对于内容
fill_parent 相对于父容器 其他属性对宽度高度没有影响
-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一二三四"
android:ems="2"
android:singleLine="true"
android:background="#ff0000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
循环显示文本
android:ellipsize=“marquee” //循环
android:marqueeRepeatLimit=“marquee_forever”//循环限制
android:focusable=“true”//第一个元素获得焦点
android:focusableInTouchMode=“true”
<TextView
android:id="@+id/textView1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_bright"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="12345678901234567890"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.164" />