Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我需要安卓布局配置_Android_Xml_Android Linearlayout - Fatal编程技术网

Android 我需要安卓布局配置

Android 我需要安卓布局配置,android,xml,android-linearlayout,Android,Xml,Android Linearlayout,70%30%布局采用线性布局的权重和。但是,图像布局不能覆盖在它上面。我的方法错了吗?您可以使用它来获得更大的灵活性 使用app:layout\u constraintHeight\u percent属性以百分比表示高度 您可以使用以下代码在两个布局之间对齐Image app:layout_constraintBottom_toTopOf="@id/layout2" app:layout_constraintTop_toBottomOf="@id/layout1" 下面是实现您

70%30%布局采用线性布局的权重和。但是,图像布局不能覆盖在它上面。我的方法错了吗?

您可以使用它来获得更大的灵活性

使用
app:layout\u constraintHeight\u percent
属性以百分比表示高度

您可以使用以下代码在两个布局之间对齐
Image

    app:layout_constraintBottom_toTopOf="@id/layout2"
    app:layout_constraintTop_toBottomOf="@id/layout1"
下面是实现您提到的布局的完整代码。



我建议您使用ConstraintLayout。它在处理此类案件方面非常有效。另外,请把你试过的代码贴出来,这样我就可以帮你了。哇!伟大的!非常感谢。没有你我不可能做到。
    <LinearLayout
        android:id="@+id/layout1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="vertical"
        app:layout_constraintBottom_toTopOf="@id/layout2"
        app:layout_constraintHeight_percent="0.7"             // 70% of height
        app:layout_constraintTop_toTopOf="parent">

    </LinearLayout>

    <LinearLayout
        android:id="@+id/layout2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:gravity="center"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHeight_percent="0.3"             // 30% of height
        app:layout_constraintTop_toBottomOf="@id/layout1">

        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_gravity="center" />

        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_gravity="center"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp" />

        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_gravity="center" />
    </LinearLayout>

    <ImageView
        android:id="@+id/image"
        android:layout_width="100dp"
        android:layout_height="100dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        // To align image between layout1 and layout2  
        app:layout_constraintBottom_toTopOf="@id/layout2"
        app:layout_constraintTop_toBottomOf="@id/layout1" />

</android.support.constraint.ConstraintLayout>