我有一个表格布局(下面的代码),但我对单元格的宽度有点问题。下图显示了问题。屏幕右侧应该有一个白色边框。我还希望文字“Auditorium” not 换行换行(我希望“13th - ”换成新行,我不想把\ n放在那里因为那意味着它会在更大的屏幕/横向视图上的那一点上进入一条新线。)
如何解决这两个问题?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#013567" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="@string/meeting_5"
android:textColor="#fff" >
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="@string/meeting_5_date"
android:textColor="#fff" >
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="@string/meeting_5_location"
android:textColor="#fff" >
</TextView>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="@string/AGM"
android:textColor="#fff" >
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="@string/AGM_date"
android:textColor="#fff" >
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="@string/AGM_location"
android:textColor="#fff" >
</TextView>
</TableRow>
</TableLayout>
答案 0 :(得分:0)
只需在xml文件中使用此代码
即可
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*"
android:stretchColumns="*"
android:layout_margin="2dp"
android:layout_gravity="center_horizontal">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="meeting_5"
android:textColor="#fff" >
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="meeting_5_date"
android:textColor="#fff" >
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="meeting_5_location"
android:textColor="#fff" >
</TextView>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="AGM"
android:textColor="#fff" >
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="AGM_date"
android:textColor="#fff" >
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/textlines"
android:gravity="center"
android:text="AGM_location"
android:textColor="#fff" >
</TextView>
</TableRow>
</TableLayout>
</ScrollView>