【问题标题】:TextView is truncated when placed in a TableLayout放置在 TableLayout 中时 TextView 被截断
【发布时间】:2011-07-20 09:27:55
【问题描述】:

我有一个使用 TextView 动态填充的 ListView:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
        <ListView
                android:id="@android:id/list"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_above="@+id/transport_selection"
                />
</LinearLayout>

但我想在 Activity 顶部添加按钮,所以我首先将我的 ListView 移动到 TableLayout 中:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

    <TableRow android:id="@+id/tableRow2" android:layout_width="fill_parent" android:layout_height="fill_parent">
        <ListView
                android:id="@android:id/list"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_above="@+id/transport_selection"
                />
   </TableRow>
</TableLayout>

但是,TextViews 中的文本被截断:它越过了屏幕的右侧。

我为 android:layout_width 属性尝试了不同的值,但没有任何改变。

有什么想法吗?

问候,

【问题讨论】:

    标签: android textview tablelayout


    【解决方案1】:

    您可以改为分别使用 addHeaderView() 或 addFooterView() 向 ListView 添加水平方向的 LinearLayout,其中包含几个按钮并完全消除 TableLayout 解决方案。这个方法我以前用过,效果很好。

    您还可以使用 RelativeLayout 浮动按钮,并使用 addHeaderView/addFooterView 插入间隔,这样它们就不会与 ListView 重叠。

    也许还有其他方法,我很想听听。

    【讨论】:

      猜你喜欢
      • 2016-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多