表格布局包装文本android

Jen*_*iza 6 android

我正在创建动态表.第一行是静态的.

<?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="#DEDEDE" >
<TableLayout 
    android:id="@+id/TableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#DEDEDE" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/DarkGray" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/Black"
            android:background="@drawable/cell_shape"
            android:text="??????"
            android:textSize="16dp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/Black"
            android:background="@drawable/cell_shape"
            android:text="?????"
            android:textSize="16dp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/cell_shape"
            android:text="??????"
            android:textColor="@color/Black"
            android:textSize="16dp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/cell_shape"
            android:text="????"
            android:textColor="@color/Black"
            android:textSize="16dp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/Black"
            android:background="@drawable/cell_shape"
            android:text="?/?"
            android:textSize="16dp"
            android:textStyle="bold" />
    </TableRow>

</TableLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

第二行和其他行是动态的,它们以编程方式填充

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/TableRow1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#DEDEDE" >
    <ImageView
        android:id="@+id/imageStatus"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/cell_shape" />

    <TextView
        android:id="@+id/textVuezd"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/cell_shape"
        android:text=""
        android:textColor="@color/Black"
        android:textSize="12dp" />

    <TextView
        android:id="@+id/textOtkuda"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/cell_shape"
        android:text=""
        android:textColor="@color/Black"
        android:textSize="12dp" />

    <TextView
        android:id="@+id/textKuda"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/cell_shape"
        android:text=""
        android:textColor="@color/Black"
        android:textSize="12dp" />

    <TextView
        android:id="@+id/textSeatsPrice"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/cell_shape"
        android:text=""
        android:textColor="@color/Black"
        android:textSize="12dp" />

</TableRow>
Run Code Online (Sandbox Code Playgroud)

我把这个表显示为对话框并得到了这个:

http://www.autostarkiev.com.ua/gg.png
Run Code Online (Sandbox Code Playgroud)

由于字体大小我只能看到整个表的一半.如何在文本视图换行中创建文本,以便我可以看到整个表格?

use*_*334 14

对于每一个TextViewTableRow替换"match_parent"与0dp和使用重量来代替.

换行:

android:layout_width="match_parent"
Run Code Online (Sandbox Code Playgroud)

到行:

android:layout_width="0dp"
android:layout_weight="1"
Run Code Online (Sandbox Code Playgroud)

如果您希望列比其他列更大,只需将权重从1更改为更大的数字.