【问题标题】:TableLayout cutting off textTableLayout 截断文本
【发布时间】:2014-01-03 02:35:27
【问题描述】:

我是 android 开发的初学者,我在谷歌上搜索了很多关于这个问题的信息,但没有成功。我的活动有一个 3 行 2 列的表格布局。结果当我使用 android:scretchColumns="1" 时,表格可以填充第二列的所有屏幕宽度部分被切断。我已经按照我的设计为第二列设置了 layout_gravity="right"。这是布局:

<?xml version="1.0" encoding="utf-8"?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/tableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:stretchColumns="1">


        <TableRow
            android:id="@+id/tableRow1"
            android:padding="5dip" >

        <TextView
            android:id="@+id/total"
            android:text="@string/total" />


        <TextView
            android:id="@+id/total_value"
            android:layout_gravity="right"
        />


    </TableRow>

    <View
        android:layout_height="2dip"
        android:background="#FF0000" />

    <TableRow
        android:id="@+id/tableRow2"
        android:padding="5dip" >

        <TextView
            android:id="@+id/qty_participant"
            android:text="@string/qty_participant" />


        <TextView
            android:id="@+id/qty_participant_value"
            android:layout_gravity="right"/>


    </TableRow>

    <View
        android:layout_height="2dip"
        android:background="#FF0000" />

    <TableRow
        android:id="@+id/tableRow3"
        android:padding="5dip" >

        <TextView
            android:id="@+id/participant_share"
            android:text="@string/participant_share"/>


        <TextView
            android:id="@+id/participant_share_value"
            android:layout_gravity="right" />


    </TableRow>

    <View
        android:layout_height="2dip"
        android:background="#FF0000" />

    </TableLayout>

我做错了什么?

【问题讨论】:

    标签: android layout text tablelayout


    【解决方案1】:

    看起来我错误地传递了 android:stretchColumns 参数。它仅拉伸第一列。使用 android:stretchColumns="*" 并删除 View.. 在 TableRows 之间解决了问题

    【讨论】:

      猜你喜欢
      • 2016-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 2020-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多