android表格布局
TableLayout部分属性解释:
collapseColumns–设置隐藏那些列,列ID从0开始,多个列的话用”,”分隔。
stretchColumns-自动扩展哪一列指定多个需逗号分隔,“*”代表平均分配
表格中的元素属性android:layout_column="1"代表在元素所在行中哪一列显示
<!--stretchColumns - 自动扩展哪一列 指定多个需逗号分隔,“*”代表平均分配-->
<!-- collapseColumns - 设置哪些列 不显示-->
<!-- translationY纵向 收缩 -->
<!-- translationX横向 收缩 -->
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:translationY="10dp"
android:translationX="10dp"
android:stretchColumns="2"
android:collapseColumns="1,3"
>
<TableRow>
<TextView
android:text="国家"
android:background="#848484"
android:translationY="10dp"
android:translationX="10dp"
android:padding="2dip"
/>
<TextView
android:text="金牌"
android:background="#ff0000"
android:padding="2dip"
/>
<TextView
android:text="银牌"
android:background="#00ff00"
android:padding="2dip"
/>
<TextView
android:text="铜牌"
android:background="#0000ff"
android:padding="2dip"
/>
</TableRow>
<TableRow >
<TextView
android:text="*"
android:background="#ff0000"
android:padding="2dip"
/>
<TextView
android:text="**"
android:background="#00ff00"
android:padding="2dip"
/>
<TextView
android:text="***"
android:background="#0000ff"
android:padding="2dip"
/>
</TableRow>
<TableRow >
<TextView
android:text="美国"
android:background="#848484"
android:padding="2dip"
/>
<TextView
android:text="*"
android:background="#ff0000"
android:padding="2dip"
/>
<TextView
android:text="**"
android:background="#00ff00"
android:padding="2dip"
/>
<TextView
android:text="***"
android:background="#0000ff"
android:padding="2dip"
/>
</TableRow>
<!-- ellipsize: -->
<!-- "end" 省略号在结尾 -->
<!-- "start" 省略号在开头 -->
<!-- "middle" 省略号在中间 -->
<!-- "marquee" 跑马灯 不仅对于textview有此属性,对于editext也有,不过editext不支持marquee -->
<!-- 最好加一个约束android:singleline = "true" -->
<EditText
android:id="@+id/edittext"
android:hint=" TextView 测试 TextView 测试 TextView 测试 TextView 测试 TextView 测试 TextView 测试TextView 测试"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"/>
</TableLayout>效果图:
相关推荐
xfcyhades 2020-11-20
Michael 2020-11-03
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28