我有一个包含6行tableLayout的日历,每行包含6个CelluleMensuelle类型的单元格(它扩展了LinearLayout)。固定桌面高度Android
在开始时,所有行都具有相同的高度,但是当我向单元格添加textviews时,它会增加行的高度,我该如何防止这种情况?我要对行保持其初始高度
这里是我的xml文件 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>
请参阅http://radioal.blogspot.in /2011/05/stretching-rows-in-android-tablelayout.html – jeevamuthu