tablerow的Android的固定高度 [英] Fixed height of tableRow Android
问题描述
我有一个包含tableLayout 6行的日历,每行包含类型CelluleMensuelle的6个细胞(其延伸出的LinearLayout)。
在开始的时候,所有行具有相同的高度,但是当我添加到textviews细胞,它增加了行的高度,我怎么能prevent呢?我要对行保持其初始高度
这里是我的xml文件
calendrier_calendriermensuel.xml
<?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=垂直><的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT>
<的TextView
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =3
机器人:文字=Lundi将军
机器人:背景=@绘制/ ligne_bordure
/>
<的TextView
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =3
机器人:文字=狂欢
机器人:背景=@绘制/ ligne_bordure
/>
<的TextView
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =3
机器人:文字=Mercredi
机器人:背景=@绘制/ ligne_bordure
/>
<的TextView
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =3
机器人:文字=Jeudi
机器人:背景=@绘制/ ligne_bordure
/>
<的TextView
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =3
机器人:文字=Vendredi
机器人:背景=@绘制/ ligne_bordure
/>
< / LinearLayout中>< TableLayout
机器人:ID =@ + ID / layout_calendriermensuel
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=#FFFFFF> <的TableRow
机器人:layout_width =match_parent
机器人:layout_height =0dp
机器人:layout_weight =1> < com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< /&的TableRow GT;
<的TableRow
机器人:layout_width =match_parent
机器人:layout_height =0dp
机器人:layout_weight =1> < com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< com.thinline.dm21.utils.CelluleMensuelle
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:背景=@绘制/ ligne_bordure
/>
< /&的TableRow GT; <! - 4人tablerows - >
< / TableLayout>< / LinearLayout中>
您需要设置了android:在TableLayout的weightSum属性,所以如果你有6行,要保持相同的高度,他们和每个行已在指标权重设置为1,Android的:在TableLayout的weightSum属性必须是6
I have a calendar that contains a tableLayout with 6 rows, each row contains 6 cells of type CelluleMensuelle (it extends a LinearLayout).
In the beginning, all rows have the same height, but when i add textviews to a cell, it increases the height of its row, how can i prevent this ? i want the rows to keep their initial height
here is my xml file calendrier_calendriermensuel.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Lundi"
android:background="@drawable/ligne_bordure"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Mardi"
android:background="@drawable/ligne_bordure"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Mercredi"
android:background="@drawable/ligne_bordure"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Jeudi"
android:background="@drawable/ligne_bordure"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Vendredi"
android:background="@drawable/ligne_bordure"
/>
</LinearLayout>
<TableLayout
android:id="@+id/layout_calendriermensuel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FFFFFF">
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
<com.thinline.dm21.utils.CelluleMensuelle
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ligne_bordure"
/>
</TableRow>
<!-- 4 others tablerows --!>
</TableLayout>
</LinearLayout>
You need to set the android:weightSum attribute of the TableLayout, so if you have 6 rows and you want to keep the same height for them and each of the row has the attribute weight set to 1, the android:weightSum attribute of the TableLayout needs to be 6.
这篇关于tablerow的Android的固定高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!