Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/133.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_Android Layout_Android Linearlayout_Android Layout Weight - Fatal编程技术网

Android 线性布局儿童体重

Android 线性布局儿童体重,android,android-layout,android-linearlayout,android-layout-weight,Android,Android Layout,Android Linearlayout,Android Layout Weight,我想要一个带权重的线性布局包含另一个带权重的线性布局。问题是,当我尝试为子布局设置权重时,它会在为LinearLayout子布局设置权重时发出性能不佳的警告。我基本上想要两个线性布局,都是50%(0.5重量),包含另一个线性布局,分为4个布局,因此一个网格有2列2行。试试看。 PercentRelativeLayout比。我会用它来做这件事。拥有和的所有最佳功能,目前谷歌正在积极改进 <?xml version="1.0" encoding="utf-8"?> <android

我想要一个带权重的线性布局包含另一个带权重的线性布局。问题是,当我尝试为子布局设置权重时,它会在为LinearLayout子布局设置权重时发出性能不佳的警告。我基本上想要两个线性布局,都是50%(0.5重量),包含另一个线性布局,分为4个布局,因此一个网格有2列2行。

试试看。
PercentRelativeLayout
比。

我会用它来做这件事。拥有和的所有最佳功能,目前谷歌正在积极改进

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <View
        android:id="@+id/r1c1"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#eee"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/r1c2"
        app:layout_constraintBottom_toTopOf="@+id/r2c1"/>

    <View
        android:id="@+id/r1c2"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#ddd"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/r1c1"
        app:layout_constraintRight_toLeftOf="@+id/r1c3"
        app:layout_constraintBottom_toTopOf="@+id/r2c2"/>

    <View
        android:id="@+id/r1c3"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#ccc"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/r1c2"
        app:layout_constraintRight_toLeftOf="@+id/r1c4"
        app:layout_constraintBottom_toTopOf="@+id/r2c3"/>

    <View
        android:id="@+id/r1c4"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#bbb"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/r1c3"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toTopOf="@+id/r2c4"/>

    <View
        android:id="@+id/r2c1"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#aaa"
        app:layout_constraintTop_toBottomOf="@+id/r1c1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/r2c2"
        app:layout_constraintBottom_toBottomOf="parent"/>

    <View
        android:id="@+id/r2c2"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#999"
        app:layout_constraintTop_toBottomOf="@+id/r1c2"
        app:layout_constraintLeft_toRightOf="@+id/r2c1"
        app:layout_constraintRight_toLeftOf="@+id/r2c3"
        app:layout_constraintBottom_toBottomOf="parent"/>

    <View
        android:id="@+id/r2c3"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#888"
        app:layout_constraintTop_toBottomOf="@+id/r1c3"
        app:layout_constraintLeft_toRightOf="@+id/r2c2"
        app:layout_constraintRight_toLeftOf="@+id/r2c4"
        app:layout_constraintBottom_toBottomOf="parent"/>

    <View
        android:id="@+id/r2c4"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#777"
        app:layout_constraintTop_toBottomOf="@+id/r1c4"
        app:layout_constraintLeft_toRightOf="@+id/r2c3"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

</android.support.constraint.ConstraintLayout>


您可以共享您的xml布局文件吗?