具有行权重的Android TableLayout

问题描述 投票:0回答:1

im试图创建表并将相同的空间添加到表中的列。我的代码在下面,但是我的第二列没有与第一个相同的空间。就像您在我下面发布的图像上看到的一样,第一行(标题)与正文(第二行)没有相同的空间。

希望有人可以帮助我取消对此有何疑问

“结果是这个”“>

我想要的

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS92MUwzQi5wbmcifQ==” alt =“在此处输入图像描述”>

我的代码是:

<TableLayout
        android:layout_width="match_parent"
        android:layout_height="0dp">

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:weightSum="1" >

            <TextView
                android:layout_height="match_parent"
                android:layout_weight="0.6" />

            <ImageView
                android:layout_height="wrap_content"
                android:layout_weight="0.1"/>

            <ImageView
                android:layout_height="wrap_content"
                android:layout_weight="0.1" />

            <ImageView
                android:layout_height="wrap_content"
                android:layout_weight="0.1"" />

            <ImageView
                android:layout_height="match_parent"
                android:layout_weight="0.1" />
        </TableRow>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
              >

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

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:weightSum="1" >

                    <TextView
                        android:layout_height="0dp"
                        android:layout_weight="0.6" />

                    <ImageView
                        android:layout_height="0dp"
                        android:layout_weight="0.1" />

                    <ImageView
                        android:layout_height="0dp"
                        android:layout_weight="0.1" />

                    <ImageView
                        android:layout_height="0dp"
                        android:layout_weight="0.1" />

                    <ImageView
                        android:layout_height="0dp"
                        android:layout_weight="0.1" />
                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:weightSum="1" >

                    <RelativeLayout
                        android:layout_height="wrap_content"
                        android:layout_weight="0.6" >        

                        <TextView
                       android:layout_width="wrap_content"
                        android:layout_height="wrap_content" 
                       />

                    </RelativeLayout>

                    <TextView
                        android:layout_height="wrap_content"
                        android:layout_weight="0.1" />

                    <TextView
                        android:layout_height="wrap_content"
                        android:layout_weight="0.1" />

                    <TextView
                        android:layout_height="wrap_content"
                        android:layout_weight="0.1" />

                    <TextView
                        android:layout_height="wrap_content"
                        android:layout_weight="0.1" />
                </TableRow>
            </TableLayout>
        </ScrollView>
    </TableLayout>

im试图创建表并将相同的空间添加到表中的列。我的代码在下面,但是我的第二列没有与第一个相同的空间。就像您在我下面发布的图片上看到的一样,...

android android-layout android-xml
1个回答
0
投票

请为标签中的项目设置layout_width =“ 0dp”,请参见以下示例

© www.soinside.com 2019 - 2024. All rights reserved.