以下是代码:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<include android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/left_center"
layout="@layout/card_center_top" />
<include android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/right_"
layout="@layout/card_center_right" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<include android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/left_bottom"
layout="@layout/card_left_bottom" />
<include android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/right_bottom"
layout="@layout/card_right_bottom" />
</LinearLayout>
它不适合每台设备,也不知道如何实现这一点。提前谢谢。
答案 0 :(得分:0)
创建以下层次结构。我已设置Black
和White
框,以便您轻松理解。
Xml代码:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red1"
android:orientation="vertical"
android:weightSum="3">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#FFFFFF"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:layout_weight="0.5">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#000000"
android:layout_weight="0.5">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#000000"
android:layout_weight="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#000000"
android:layout_weight="0.5"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:layout_weight="0.5">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#FFFFFF"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:layout_weight="0.5">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#000000"
android:layout_weight="0.5">
</LinearLayout>
</LinearLayout>
</LinearLayout>
输出
答案 1 :(得分:0)
使用相对布局概念
<RelativeLayout ..>
</RelativeLayout>
浏览此链接https://developer.android.com/guide/topics/ui/layout/relative.html#Example