如何拆分android屏幕水平2垂直3总计6
好的,我试着将屏幕大小分成水平方向和垂直方向各3个部分 windows 8.1 api 9上的Android studio 这是我想要的图像 每个图像的大小正好是这些,我希望它们根据较低的分辨率按比例缩放 这里是我尝试过但失败的代码如何拆分android屏幕水平2垂直3总计6,android,android-layout,android-studio,android-imagebutton,Android,Android Layout,Android Studio,Android Imagebutton,好的,我试着将屏幕大小分成水平方向和垂直方向各3个部分 windows 8.1 api 9上的Android studio 这是我想要的图像 每个图像的大小正好是这些,我希望它们根据较低的分辨率按比例缩放 这里是我尝试过但失败的代码 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Pokemon"
android:background="@color/background_floating_material_dark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_1"
android:background="@null"
android:src="@drawable/bg_monstermmorpg_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_2"
android:background="@null"
android:src="@drawable/Register_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_monstermmorpg"
android:background="@null"
android:src="@drawable/Login_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_1"
android:background="@null"
android:src="@drawable/bg_pokemonpets_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_2"
android:background="@null"
android:src="@drawable/Register_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_pokemonpets"
android:background="@null"
android:src="@drawable/Login_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
</LinearLayout>
这里的诀窍是使用一个
线性布局
作为父级,权重和为4,方向为垂直。然后使用3个LinearLayout
childs,其中weightSum
为2,orientation
水平,weight
为2,第二个和第三个为1。在这些线性布局中
放置2个ImageButton
,其中权重为1
如果你想要一个例子,告诉我,但我认为我很清楚
另外,所有的布局宽度
和布局高度
必须与父级
匹配这里的技巧是使用一个线性布局
作为父级,权重和为4,方向为垂直。然后使用3个LinearLayout
childs,其中weightSum
为2,orientation
水平,weight
为2,第二个和第三个为1。在这些线性布局中
放置2个ImageButton
,其中权重为1
如果你想要一个例子,告诉我,但我认为我很清楚
另外,所有的布局宽度
和布局高度
必须与父级
匹配这里的技巧是使用一个线性布局
作为父级,权重和为4,方向为垂直。然后使用3个LinearLayout
childs,其中weightSum
为2,orientation
水平,weight
为2,第二个和第三个为1。在这些线性布局中
放置2个ImageButton
,其中权重为1
如果你想要一个例子,告诉我,但我认为我很清楚
另外,所有的布局宽度
和布局高度
必须与父级
匹配这里的技巧是使用一个线性布局
作为父级,权重和为4,方向为垂直。然后使用3个LinearLayout
childs,其中weightSum
为2,orientation
水平,weight
为2,第二个和第三个为1。在这些线性布局中
放置2个ImageButton
,其中权重为1
如果你想要一个例子,告诉我,但我认为我很清楚
另外,所有的layout\u width
和layout\u height
必须是match\u parent
我想你可以使用GridView
在布局方面,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Pokemon"
android:background="@color/background_floating_material_dark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightsum="2"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation:vertical
android:weightsum="3"
android:layout_weight="1">
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_monstermmorpg_1"
android:background="@null"
android:src="@drawable/bg_monstermmorpg_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_monstermmorpg_2"
android:background="@null"
android:src="@drawable/Register_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/login_monstermmorpg"
android:background="@null"
android:src="@drawable/Login_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation:vertical
android:weightsum="3"
android:layout_weight="1">
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_pokemonets_1"
android:background="@null"
android:src="@drawable/bg_pokemonpets_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_pokemonets_2"
android:background="@null"
android:src="@drawable/Register_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/login_pokemonpets"
android:background="@null"
android:src="@drawable/Login_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_1"
android:background="@null"
android:src="@drawable/bg_monstermmorpg_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_2"
android:background="@null"
android:src="@drawable/Register_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_monstermmorpg"
android:background="@null"
android:src="@drawable/Login_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_1"
android:background="@null"
android:src="@drawable/bg_pokemonpets_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_2"
android:background="@null"
android:src="@drawable/Register_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_pokemonpets"
android:background="@null"
android:src="@drawable/Login_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</LinearLayout>
</LinearLayout>
我认为您可以简单地使用GridView
在布局方面,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Pokemon"
android:background="@color/background_floating_material_dark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightsum="2"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation:vertical
android:weightsum="3"
android:layout_weight="1">
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_monstermmorpg_1"
android:background="@null"
android:src="@drawable/bg_monstermmorpg_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_monstermmorpg_2"
android:background="@null"
android:src="@drawable/Register_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/login_monstermmorpg"
android:background="@null"
android:src="@drawable/Login_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation:vertical
android:weightsum="3"
android:layout_weight="1">
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_pokemonets_1"
android:background="@null"
android:src="@drawable/bg_pokemonpets_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_pokemonets_2"
android:background="@null"
android:src="@drawable/Register_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/login_pokemonpets"
android:background="@null"
android:src="@drawable/Login_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_1"
android:background="@null"
android:src="@drawable/bg_monstermmorpg_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_2"
android:background="@null"
android:src="@drawable/Register_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_monstermmorpg"
android:background="@null"
android:src="@drawable/Login_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_1"
android:background="@null"
android:src="@drawable/bg_pokemonpets_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_2"
android:background="@null"
android:src="@drawable/Register_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_pokemonpets"
android:background="@null"
android:src="@drawable/Login_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</LinearLayout>
</LinearLayout>
我认为您可以简单地使用GridView
在布局方面,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Pokemon"
android:background="@color/background_floating_material_dark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightsum="2"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation:vertical
android:weightsum="3"
android:layout_weight="1">
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_monstermmorpg_1"
android:background="@null"
android:src="@drawable/bg_monstermmorpg_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_monstermmorpg_2"
android:background="@null"
android:src="@drawable/Register_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/login_monstermmorpg"
android:background="@null"
android:src="@drawable/Login_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation:vertical
android:weightsum="3"
android:layout_weight="1">
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_pokemonets_1"
android:background="@null"
android:src="@drawable/bg_pokemonpets_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_pokemonets_2"
android:background="@null"
android:src="@drawable/Register_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/login_pokemonpets"
android:background="@null"
android:src="@drawable/Login_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_1"
android:background="@null"
android:src="@drawable/bg_monstermmorpg_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_2"
android:background="@null"
android:src="@drawable/Register_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_monstermmorpg"
android:background="@null"
android:src="@drawable/Login_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_1"
android:background="@null"
android:src="@drawable/bg_pokemonpets_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_2"
android:background="@null"
android:src="@drawable/Register_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_pokemonpets"
android:background="@null"
android:src="@drawable/Login_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</LinearLayout>
</LinearLayout>
我认为您可以简单地使用GridView
在布局方面,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Pokemon"
android:background="@color/background_floating_material_dark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightsum="2"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation:vertical
android:weightsum="3"
android:layout_weight="1">
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_monstermmorpg_1"
android:background="@null"
android:src="@drawable/bg_monstermmorpg_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_monstermmorpg_2"
android:background="@null"
android:src="@drawable/Register_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/login_monstermmorpg"
android:background="@null"
android:src="@drawable/Login_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation:vertical
android:weightsum="3"
android:layout_weight="1">
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_pokemonets_1"
android:background="@null"
android:src="@drawable/bg_pokemonpets_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/register_pokemonets_2"
android:background="@null"
android:src="@drawable/Register_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/login_pokemonpets"
android:background="@null"
android:src="@drawable/Login_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_1"
android:background="@null"
android:src="@drawable/bg_monstermmorpg_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_monstermmorpg_2"
android:background="@null"
android:src="@drawable/Register_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_monstermmorpg"
android:background="@null"
android:src="@drawable/Login_monstermmorpg_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_1"
android:background="@null"
android:src="@drawable/bg_pokemonpets_button_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/register_pokemonets_2"
android:background="@null"
android:src="@drawable/Register_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_pokemonpets"
android:background="@null"
android:src="@drawable/Login_pokemonpets_land"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
</LinearLayout>
</LinearLayout>
首先,您需要一个权重和为2的水平线性布局。
内部应有2个垂直线性布局,权重和为4,每个权重为1。
在这两个布局中,添加3个图像按钮。顶部的权重为2,其他部分的权重为1首先,您需要一个权重和为2的水平线性布局。
Using layout weight can be a good solution.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button02"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button3" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button05"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button3" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button04"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button03"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
内部应有2个垂直线性布局,权重和为4,每个权重为1。
在这两个布局中,添加3个图像按钮。顶部的权重为2,其他部分的权重为1首先,您需要一个权重和为2的水平线性布局。
Using layout weight can be a good solution.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button02"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button3" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button05"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button3" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button04"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button03"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
内部应有2个垂直线性布局,权重和为4,每个权重为1。
在这两个布局中,添加3个图像按钮。顶部的权重为2,其他部分的权重为1首先,您需要一个权重和为2的水平线性布局。
Using layout weight can be a good solution.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button02"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button3" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button05"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button3" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button04"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button03"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
内部应有2个垂直线性布局,权重和为4,每个权重为1。
在这两个布局中,添加3个图像按钮。顶部的权重为2,其他部分的权重为1使用布局权重可以是一个很好的解决方案。
Using layout weight can be a good solution.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button02"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button3" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button05"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button3" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button04"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/Button03"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
使用布局权重是一个很好的解决方案。
使用布局权重是一个很好的解决方案。
使用布局权重是一个很好的解决方案。