TextView控件常用属性
- android:layout_width 设置控件宽度
- android:layout_height 设置控件的高度
- android:id 设置组建id
- android:text 设置文本内容
- android:textColor 设置文本颜色
- android:textSize 设置文本大小
- android:background 设置控件的背景色
- android:gravity 设置文本相对控件的位置
- android:layout_gravity 设置控件相对于其所在容器的位置
其中match_parent:控件大小与父布局一样
wrap_contents:控件大小刚好包含所输入内容大小,大小与其中的内容一致
例如:
android:ellipsize=“marquee” //跑马灯效果
android:focusable=“true” //让控件可获取焦点
android:focusableInTouchMode=“true” // 让控件在触摸模式下获取焦点
可选的属性:android:marqueeRepeatLimit //文本滚动的次数
属性值:-1或marquee_forever,代表无限滚动
具体的滚动次数(比如设置为2)
EditText
- android:hint 输入提示
- android:textColorHint 提示的颜色
- android:textColorHighlight 选中字体的背景颜色
- android:inputType 输入类型的可选项