我在游戏中工作然后我遇到了问题。在我的游戏中,我TableLayout
五TableLayout
TableRow
以及每TableRow
五LinearLayout
LinearLayout
个ImageView
有一个LinearLayouts
ImageView's
}。现在我们有二十五ImageView's
。游戏取决于删除weight = "1"
。
问题是当我删除同一行或列中的TableLayout
时,该行或列的大小会缩小。为什么会这样?
我认为原因是因为我为weight = "0.2"
添加了TableRow
,为weight = "0.2"
添加了Linearlayout
并为<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/table"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp" >
<TableRow
android:id="@+id/tableRow_1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2" >
<LinearLayout
android:tag="11"
android:id="@+id/L_11"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand" >
<ImageView
android:id="@+id/piece_1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:tag="12"
android:id="@+id/L_12"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand" >
<ImageView
android:id="@+id/piece_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:tag="13"
android:id="@+id/L_13"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand" >
<ImageView
android:id="@+id/piece_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:tag="14"
android:id="@+id/L_14"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand" >
<ImageView
android:id="@+id/piece_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:tag="15"
android:id="@+id/L_15"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand" >
<ImageView
android:id="@+id/piece_5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow_2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2" >
<LinearLayout
android:id="@+id/L_21"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="21" >
<ImageView
android:id="@+id/piece_6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_22"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="22" >
<ImageView
android:id="@+id/piece_7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_23"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="23" >
<ImageView
android:id="@+id/piece_8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_24"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="24" >
<ImageView
android:id="@+id/piece_9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_25"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="25" >
<ImageView
android:id="@+id/piece_10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow_3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2" >
<LinearLayout
android:id="@+id/L_31"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="31" >
<ImageView
android:id="@+id/piece_11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_32"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:orientation="horizontal"
android:tag="32" >
<ImageView
android:id="@+id/piece_12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece1"
android:tag="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_33"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="33" >
</LinearLayout>
<LinearLayout
android:id="@+id/L_34"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="34" >
<ImageView
android:id="@+id/piece_13"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_35"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="35" >
<ImageView
android:id="@+id/piece_14"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow_4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2" >
<LinearLayout
android:id="@+id/L_41"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="41" >
<ImageView
android:id="@+id/piece_15"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_42"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="42" >
<ImageView
android:id="@+id/piece_16"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_43"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="43" >
<ImageView
android:id="@+id/piece_17"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_44"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="44" >
<ImageView
android:id="@+id/piece_18"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_45"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="45" >
<ImageView
android:id="@+id/piece_19"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow_5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2" >
<LinearLayout
android:id="@+id/L_51"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="51" >
<ImageView
android:id="@+id/piece_20"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_52"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="52" >
<ImageView
android:id="@+id/piece_21"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_53"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="53" >
<ImageView
android:id="@+id/piece_22"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_54"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="54" >
<ImageView
android:id="@+id/piece_23"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/L_55"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/area_sand"
android:tag="55" >
<ImageView
android:id="@+id/piece_24"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="@drawable/piece2"
android:tag="0" />
</LinearLayout>
</TableRow>
</TableLayout>
添加了{{1}}。
现在,如果我认为是正确的。如何使我的布局适合每个屏幕。
代码将解释我想念的内容。
{{1}}