【发布时间】:2016-02-12 00:05:48
【问题描述】:
我的 TableLayout 出现问题,显示的列未对齐, 并且通过看到按钮上的文本被剪切,视图变得越来越小。
XML 布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="3dp"
android:layout_weight="2"
android:paddingTop="4dp"
android:orientation="horizontal">
<TextView
android:id="@id/libStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType = "fitXY"/>
</LinearLayout>
<TableLayout
android:id="@+id/headerTable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:stretchColumns="0,1"
android:shrinkColumns="1">
<TableRow android:id="@+id/headerRow"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/header_col1"
android:textColor="@android:color/black"
android:layout_marginLeft="1dp"
android:gravity="center_horizontal"
android:layout_weight="1"
android:background="@drawable/cell_shape"
android:text="@string/lib_dev_name" />
<TextView
android:id="@+id/header_col2"
android:textColor="@android:color/black"
android:gravity="center_horizontal"
android:layout_weight="1"
android:layout_marginRight="1dp"
android:background="@drawable/cell_shape1"
android:text="@string/lib_status" />
</TableRow>
</TableLayout>
<ScrollView
android:id="@+id/table_scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp">
<TableLayout
android:id="@+id/table_devices"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:stretchColumns="0,1"
android:shrinkColumns="1" >
<TableRow>
<TextView
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginLeft="1dp"
android:gravity="center_horizontal"
android:text="Col1" />
<CheckBox
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginRight="1dp"
android:gravity="center_horizontal"
android:text="Col2" />
</TableRow>
</TableLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="3dp"
android:layout_weight="2"
android:paddingTop="4dp"
android:orientation="horizontal">
<Button
android:id="@id/btnConnect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType = "fitXY"
android:text="@string/lib_connect"/>
<Button
android:id="@id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType = "fitXY"
android:text="@string/lib_cancel"/>
</LinearLayout>
这是我运行应用程序时布局的显示方式:
请各位大侠指教。
提前谢谢你。
【问题讨论】:
标签: android scrollview tablelayout