由网友(爱走了不要绝望)分享简介:我使用的表布局如下图显示的数据。I am using Table Layout to display data as shown below.我想要做什么? 我想在第二列中的文本要左对齐和文字换行应在下一行,过流,你在图像中看到显示出来。I want the Text in the second column to...
我使用的表布局如下图显示的数据。
I am using Table Layout to display data as shown below.
我想要做什么?
我想在第二列中的文本要左对齐和文字换行应在下一行,过流,你在图像中看到显示出来。
I want the Text in the second column to be aligned to the left and the text should wrap and be displayed in the next line and over flow as you see in the image.
code:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp" >
<ImageView
android:id="@+id/place_category_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:contentDescription="ss"
android:paddingRight="10dp"
android:src="@drawable/icon_category"
android:textAlignment="textStart" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:text="230 kms"
android:textSize="16sp" >
</TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp" >
<ImageView
android:id="@+id/place_category_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:contentDescription="ss"
android:paddingRight="10dp"
android:src="@drawable/icon_category"
android:textAlignment="textStart" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:text="Hill Station, Wild Life"
android:textSize="16sp" >
</TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp" >
<ImageView
android:id="@+id/place_category_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:contentDescription="ss"
android:paddingRight="10dp"
android:src="@drawable/icon_category"
android:textAlignment="textStart" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:text="Summer 23-40°C, Winter 10-32°C"
android:textSize="16sp" >
</TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp" >
<ImageView
android:id="@+id/place_category_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:contentDescription="ss"
android:paddingRight="10dp"
android:src="@drawable/icon_category"
android:textAlignment="textStart" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:text="Tippus Drop, Tippus Summer Residence, Brahmashram, Cycling, Paragliding"
android:textSize="16sp" >
</TextView>
</TableRow>
</TableLayout>
它应该是什么样子
What it should look like
推荐答案
我能想到的最简单的方法是将包装每个的TableRow
的内容与的LinearLayout
是这样的:
The easiest way I can think of is to wrap each TableRow
content with a LinearLayout
like this:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/place_category_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:contentDescription="ss"
android:paddingRight="10dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:text="230 kms"
android:textSize="16sp" >
</TextView>
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/place_category_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:contentDescription="ss"
android:paddingRight="10dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:text="Hill Station, Wild Life"
android:textSize="16sp" >
</TextView>
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/place_category_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:contentDescription="ss"
android:paddingRight="10dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:text="Summer 23-40°C, Winter 10-32°C"
android:textSize="16sp" >
</TextView>
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/place_category_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:contentDescription="ss"
android:paddingRight="10dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:text="Tippus Drop, Tippus Summer Residence, Brahmashram, Cycling, Paragliding"
android:textSize="16sp" >
</TextView>
</LinearLayout>
</TableRow>
</TableLayout>
这是结果:
希望我正确地理解你的要求。
Hope I correctly understood your requirements.
相关推荐
最新文章