Android layout 线性布局中的重力-android?
我创建了以下布局:Android layout 线性布局中的重力-android?,android-layout,android-linearlayout,android-gravity,Android Layout,Android Linearlayout,Android Gravity,我创建了以下布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" androi
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeStart"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back"
tools:context=".SongsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/header"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/felesh_m" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center_vertical"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical">
<ImageButton
android:id="@+id/imbCenter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:background="@null"
android:src="@drawable/hosein_hlarge" />
</LinearLayout>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/felesh_m" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4" />
</LinearLayout>
</RelativeLayout>
像这样更改布局。您不需要采用多个线性布局
。这对性能不利。所以我把它改成了单线性布局
,带有一些权重
属性
像这样更改布局。您不需要采用多个线性布局
。这对性能不利。所以我把它改成了单线性布局
,带有一些权重
属性
检查下面的我的答案,如果您面临任何问题,请告诉我。检查下面的我的答案,如果您面临任何问题,请告诉我。不需要相对值或第一行布局。我会删除两个LinearLayout,因为所有这些都可以通过使用单个RelativeLayout来完成。让你的用户界面更快responsiveness@Rotwang先生,他在垂直方向上拍摄了<代码>回收者视图
,然后他希望在水平方向上再拍摄3张图像,这就是为什么他可能会这样设置的原因。@JoJoRoid接受并向上投票答案,如果答案对您有帮助。再次强调:所有这些都可以通过使用单个RelativeLayout来完成。如果您知道如何使用它。@Rotwang您是对的,先生,它可以使用单个相对布局。但是到目前为止,我只想解释一下,先生。相对布局或第一个线性布局是不必要的。我会删除两个LinearLayout,因为所有这些都可以通过使用单个RelativeLayout来完成。让你的用户界面更快responsiveness@Rotwang先生,他在垂直方向上拍摄了<代码>回收者视图
,然后他希望在水平方向上再拍摄3张图像,这就是为什么他可能会这样设置的原因。@JoJoRoid接受并向上投票答案,如果答案对您有帮助。再次强调:所有这些都可以通过使用单个RelativeLayout来完成。如果你知道如何使用它。@Rotwang你是对的,先生,它可以使用单个相对布局来完成。但是到现在为止,我只需要解释一下,先生。