【问题标题】:Equal TextView in TableLayoutTableLayout中相等的TextView
【发布时间】:2013-05-08 08:12:49
【问题描述】:

我想在我的应用程序中创建来自 a'la tiles metro 的统计信息。不幸的是,TextView 的宽度不相等,因为它解决了?

This is my layout

【问题讨论】:

  • 据我了解,问题可能是因为你放了 android:layout_width="match_parent" ,试着给它一个符合你需要的值
  • 嗨,Artur,欢迎来到社区,您能详细描述一下您的问题吗?
  • 我认为模仿其他 UI 元素(如 android 设计指南中所述)不是一个好主意:developer.android.com/design/patterns/pure-android.html
  • 这是我的布局:postimg.org/image/lz45maoo1 不幸的是,图块的扩展取决于 TextView 文本的长度

标签: android android-layout android-tablelayout


【解决方案1】:

使用android:weightSum 和 android:layout_weight

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="4" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="1dp"
            android:layout_weight="2"
            android:background="#B0B0B0" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="1dp"
            android:layout_weight="2"
            android:background="#B0B0B0" />

    </TableRow>

</TableLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-28
    • 2019-08-14
    • 1970-01-01
    相关资源
    最近更新 更多