本文介绍了表布局以相等行高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个TableLayout,我想每一行有相同的高度,不管它的内容。我怎样才能做到这一点?

下面是我的code。每个行元素得到相同的宽度,但高度不相等。我究竟做错了什么?

 < TableLayout
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT机器人:背景=@彩色/灰度
                机器人:填充=1dip>

                <的TableRow
                    机器人:layout_width =FILL_PARENT
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =1
                    机器人:背景=@彩色/灰度>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =FILL_PARENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:layout_marginTop =2DIP
                            机器人:layout_weight =1
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_make
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carMake
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =FILL_PARENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginLeft =1dip
                            机器人:layout_weight =1
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_detail/>
                    < / LinearLayout中>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =FILL_PARENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:layout_marginTop =2DIP
                            机器人:layout_weight =1
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_model
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carModel
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =FILL_PARENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_weight =1
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_detail/>
                    < / LinearLayout中>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =FILL_PARENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:layout_marginTop =2DIP
                            机器人:layout_weight =1
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_version
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =FILL_PARENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_weight =1
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>
                < /的TableRow>

                <的TableRow
                    机器人:layout_width =FILL_PARENT
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_marginTop =1dip
                    机器人:layout_weight =1
                    机器人:背景=@彩色/灰度>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:layout_marginTop =2DIP
                            机器人:背景=@色/白
                                机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:layout_marginTop =2DIP
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_mileage
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:layout_marginTop =2DIP
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_engine_capacity
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =FILL_PARENT
                            机器人:layout_gravity =center_vertical
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>
                < /的TableRow>

                <的TableRow
                    机器人:layout_width =FILL_PARENT
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_marginTop =1dip
                    机器人:layout_weight =1
                    机器人:背景=@彩色/灰度>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_engine_type
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_exterior_color
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_city
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>
                < /的TableRow>

                <的TableRow
                    机器人:layout_width =FILL_PARENT
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_marginTop =1dip
                    机器人:layout_weight =1
                    机器人:背景=@彩色/灰度>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_transmittion
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>

                    <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_area
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>

                        <的LinearLayout
                        机器人:layout_width =0dip
                        机器人:layout_height =FILL_PARENT
                        机器人:layout_weight =1
                        机器人:背景=@色/白
                        机器人:方向=垂直>

                        <的TextView
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:layout_marginBottom =5dip
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_registered_city
                            机器人:TEXTSTYLE =黑体/>

                        <的TextView
                            机器人:ID =@ + ID / carYear
                            机器人:layout_width =FILL_PARENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_gravity =center_vertical
                            机器人:背景=@色/白
                            机器人:重力=center_horizo​​ntal
                            机器人:文本=@字符串/ car_year/>
                    < / LinearLayout中>
                < /的TableRow>
            < / TableLayout>
 

解决方案

您可以在您的TableRow修改 - > 的LinearLayout

 <的LinearLayout
                    机器人:layout_width =0dip
                    机器人:layout_height =WRAP_CONTENT
                    机器人:layout_weight =1
                    机器人:背景=@色/白
                    机器人:方向=垂直>
 

I have created a TableLayout where I want each row to have the same height, regardless of it's content.How can I do this?

Here is my code. Each row element get the same width, but the heights are not equal. What am I doing wrong?

 <TableLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"                    android:background="@color/grey"
                android:padding="1dip" >

                <TableRow
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:background="@color/grey" >

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:layout_marginTop="2dip"
                            android:layout_weight="1"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_make"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carMake"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:layout_gravity="center_vertical"
                            android:layout_marginLeft="1dip"
                            android:layout_weight="1"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_detail" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:layout_marginTop="2dip"
                            android:layout_weight="1"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_model"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carModel"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_detail" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:layout_marginTop="2dip"
                            android:layout_weight="1"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_version"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>
                </TableRow>

                <TableRow
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginTop="1dip"
                    android:layout_weight="1"
                    android:background="@color/grey" >

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:layout_marginTop="2dip"
                            android:background="@color/white"
                                android:gravity="center_horizontal"
                            android:text="@string/car_year"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:layout_marginTop="2dip"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_mileage"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:layout_marginTop="2dip"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_engine_capacity"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:layout_gravity="center_vertical"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>
                </TableRow>

                <TableRow
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginTop="1dip"
                    android:layout_weight="1"
                    android:background="@color/grey" >

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_engine_type"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_exterior_color"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_city"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>
                </TableRow>

                <TableRow
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginTop="1dip"
                    android:layout_weight="1"
                    android:background="@color/grey" >

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_transmittion"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_area"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>

                        <LinearLayout
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@color/white"
                        android:orientation="vertical" >

                        <TextView
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="5dip"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_registered_city"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/carYear"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:background="@color/white"
                            android:gravity="center_horizontal"
                            android:text="@string/car_year" />
                    </LinearLayout>
                </TableRow>
            </TableLayout>
解决方案

You can Change in your TableRow -> LinearLayout

<LinearLayout
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="@color/white"
                    android:orientation="vertical" >

这篇关于表布局以相等行高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-28 02:56