TableLayout和TableRow的使用
来源:互联网 发布:centos 32位下载 编辑:程序博客网 时间:2024/04/25 16:06
今天写一个布局纠结了好久。我想我也说不明白难在哪里。这里记录一下以后方便查阅。
要实现的效果:
重点是:每一个Item的左边是一个Button,我设置了有对齐,宽度为40dp,右边的文字布局,就是绿色背景的部分,要在Button的左边,并且根据屏幕的不同大小,绿色的部分会自由伸缩,这样在横布局的时候都能保值一致的布局。看代码;
<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingBottom="8dp" android:paddingLeft="8dp" android:paddingTop="8dp" android:shrinkColumns="0" android:stretchColumns="0" > <TableRow> <RelativeLayout android:id="@+id/borrowed_content" > <TextView android:id="@+id/borrowed_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:singleLine="true" android:text="TextView01" android:textColor="#000000" android:textSize="15dip" /> <TextView android:id="@+id/borrowed_date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/borrowed_title" android:text="TextView" android:textColor="#AAAAAA" android:textSize="10dip" /> <TextView android:id="@+id/lent_date" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_below="@+id/borrowed_title" android:gravity="right" android:singleLine="true" android:text="TextView" android:textColor="#AAAAAA" android:textSize="10dip" /> <!-- 显示搜索结果时附加的信息 --> <TextView android:id="@+id/publish_date_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/borrowed_date" android:text="出版年:" android:textColor="#AAAAAA" android:textSize="10dip" android:visibility="gone" /> <TextView android:id="@+id/publish_date_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/borrowed_date" android:layout_toRightOf="@+id/publish_date_title" android:textColor="#AAAAAA" android:textSize="10dip" android:visibility="gone" /> <TextView android:id="@+id/borrowable_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_below="@+id/borrowed_date" android:textColor="#AAAAAA" android:textSize="10dip" android:visibility="gone" /> <TextView android:id="@+id/borrowable_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/borrowed_date" android:layout_toLeftOf="@+id/borrowable_content" android:text="可借:" android:textColor="#AAAAAA" android:textSize="10dip" android:visibility="gone" /> </RelativeLayout> <!-- 显示搜索结果时附加的信息 --> <Button android:id="@+id/button_next" android:layout_width="40dp" android:layout_height="wrap_content" android:layout_gravity="right|center" android:gravity="center" android:background="@drawable/icon_next" android:clickable="true" android:focusable="false" android:scaleType="centerInside" /> </TableRow></TableLayout>
android:shrinkColumns="0" android:stretchColumns="0" >要同时设置第0列,也就是绿色部分要同时能收缩和延伸。如果只是设置一个,起不到这样的作用。
相关的参考:http://my.oschina.net/taoyy/blog/53325
- TableLayout和TableRow的使用
- android-TableLayout以及TableRow的使用
- TableLayout和TableRow注意事项
- 界面布局TableLayout+TableRow
- 在TableLayout中使用TableRow对象来定义多行
- 在TableLayout中使用TableRow对象来定义多行
- TableLayout和TableRow容器在API中的描述
- TableLayout和ViewPager的使用
- TableLayout+TableRow 实现表格显示
- PullToRefresh和TableLayout,fragment的联合使用
- Android TableLayout\TableRow内的控件占据空间的比例问题
- Android应用view组件tablelayout应用(tablerow中的属性的应用)
- 在相对布局下用TableLayout(TableRow)控件不能居中的问题
- Table 、TableRow 和 TableCell 的简单应用
- Android TableLayout TableRow点击变色效果
- TableLayout的使用
- TableLayout的简单使用
- TableLayout的使用
- mvc中json格式的使用方法示例
- Java注解(2)
- Hibernate中复合主键映射
- mount & umount
- poj 1301 Jungle Roads
- TableLayout和TableRow的使用
- 安装Zend Studio
- 第八章 流 04_BufferedIO
- LifecyclePhaseNotFoundException(run goal with eclipse)
- hdu 1392 Surround the Trees
- python内置函数:lambda、map、filter
- android一种较为复杂的布局参考(xml文件)
- 信号量IPC
- UINavigationController使用详解