Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了表格布局包装文本android大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在创建动态表.第一行是静态的.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://scheR_966_11845@as.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>

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

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://scheR_966_11845@as.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>

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

http://www.autostarkiev.com.ua/gg.png

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

@H_874_15@解决方法
对于TableRow中的每个TextView,将“match_parent”替换为0dp并改为使用weight.

换行:

android:layout_width="match_parent"

到行:

android:layout_width="0dp"
android:layout_weight="1"

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

大佬总结

以上是大佬教程为你收集整理的表格布局包装文本android全部内容,希望文章能够帮你解决表格布局包装文本android所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。