按钮控件Button由TextView派生而来,它们之间的区别有:
Button拥有默认的按钮背景,而TextView默认无背景;
Button的内部文本默认居中对齐,而TextView的内部文本默认靠左对齐;
Button会默认将英文字母转为大写,而TextView保持原始的英...
yekong
2年前 (2022-12-31)
喜欢
滚动视图有两种:
ScrollView,它是垂直方向的滚动视图;垂直方向滚动时,layout_width属性值设置为match_p
arent, layout height属性值设置为wrap_content。
HorizontalScrollView,它是水平方向的滚动视图;水...
yekong
2年前 (2022-12-31)
喜欢
网格布局支持多行多列的表格排列。
网格布局默认从左往右、从上到下排列,它新增了两个属性:
columnCount属性,它指定了网格的列数,即每行能放多少个视图;
rowCount属性,它指定了网格的行数,即每列能放多少个视图;
<?xml version="1.0...
yekong
2年前 (2022-12-31)
喜欢
相对布局的下级视图位置由其他视图决定。用于确定下级视图位置的参照物分两种:
与该视图自身平级的视图;
该视图的上级视图(也就是它归属的RelativeLayout)
如果不设定下级视图的参照物,那么下级视图默认显示在RelativeLayout内部的左上角。
相对位置取值
&l...
yekong
2年前 (2022-12-31)
喜欢
线性布局内部的各视图有两种排列方式:
orientation属性值为horizontal时,内部视图在水平方向从左往右排列。
orientation属性值为vertical时,内部视图在垂直方向从上往下排列。
如果不指定orientation属性,则LinearLayout默认水...
yekong
2年前 (2022-12-31)
喜欢
设置视图的对齐方式有两种途径:
采用layout_gravity属性,它指定了当前视图相对于上级视图的对齐方式。
采用gravity属性,它指定了下级视图相对于当前视图的对齐方式。
layout_gravity与gravity的取值包括:left、 top、 right、 bot...
yekong
2年前 (2022-12-31)
喜欢
设置视图的间距有两种方式:
采用layout_margin属性,它指定了当前视图与周围平级视图之间的距离。包括layout_margin、
layout_marginLeft、 layout_marginTop、 layout_marginRight. layout_margin...
yekong
2年前 (2022-12-31)
喜欢
视图宽度通过属性androidlayout_width表达,视图高度通过属性android:layout_heig
ht表达,宽高的取值主要有下列三种:
match_parent:表示与上级视图保持一致。
wrap_content:表示与内容自适应。
以dp为单位的具体尺寸。
x...
yekong
2年前 (2022-12-31)
喜欢
java设置背景颜色
使用setBackgroundColor或者setBackgroundResource设置背景色
package com.example.chapter03;
import android.graphics.Color;
import android.os...
yekong
2年前 (2022-12-30)
喜欢
java设置文字颜色
setTextColor
package com.example.chapter03;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextV...
yekong
2年前 (2022-12-30)
喜欢