Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.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_User Interface_Android Relativelayout_Material Design - Fatal编程技术网

Android 无嵌套的相对性

Android 无嵌套的相对性,android,android-layout,user-interface,android-relativelayout,material-design,Android,Android Layout,User Interface,Android Relativelayout,Material Design,嗨,我试着复制下面的例子 我是这样做的,但是有一个亲戚你,所以我想知道她是不是我的密码的好方法 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" andr

嗨,我试着复制下面的例子

我是这样做的,但是有一个亲戚你,所以我想知道她是不是我的密码的好方法

<RelativeLayout 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:background="@color/text_primary"
            tools:context=".MainActivity">
<include layout="@layout/toolbar"
         android:id="@+id/toolbar"/>

<ImageView android:layout_width="wrap_content"
           android:layout_below="@+id/toolbar"
           android:layout_marginTop="28dp"
           android:paddingStart="16dp"
           android:paddingEnd="2dp"
           android:id="@+id/icon_pizza"
           android:src="@drawable/cutlery22"
           android:layout_height="wrap_content"/>
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Morning Pizza"
        android:id="@+id/textView"
        android:layout_alignTop="@+id/icon_pizza"
        android:layout_toEndOf="@+id/icon_pizza"
        android:layout_marginStart="25dp"/>
<Button
        android:layout_width="130dp"
        android:layout_height="35dp"
        android:gravity="center"
        android:background="@color/text_primary"
        android:textAlignment="gravity"
        android:text="FORCE STOP"
        android:stateListAnimator="@drawable/button_elevation"
        android:id="@+id/button"
        android:layout_below="@+id/textView"
        android:layout_alignStart="@+id/textView"
        android:layout_marginTop="10dp"/>
<Button
        android:layout_width="130dp"
        android:layout_height="35dp"
        android:background="@color/uninstall"
        android:text="UNINSTALL"
        android:textColor="@color/text_primary"
        android:stateListAnimator="@drawable/button_elevation"
        android:id="@+id/button2"
        android:layout_alignBottom="@+id/button"
        android:layout_toEndOf="@+id/button"
        android:layout_marginStart="15dp"/>
<CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Show notifications"
        android:id="@+id/checkBox"
        android:layout_marginTop="10dp"
        android:layout_below="@+id/button"
        android:layout_alignStart="@+id/button"/>
<View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_marginTop="10dp"
        android:id="@+id/divider"
        android:layout_below="@+id/checkBox"
        android:background="@android:color/darker_gray"/>

<ImageView android:layout_width="wrap_content"
           android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
           android:id="@+id/storage_image"
           android:src="@drawable/server40"
        android:layout_below="@+id/divider"
           android:paddingStart="16dp"
           android:paddingEnd="2dp"/>
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Storage"
        android:id="@+id/storage"
        android:layout_alignTop="@+id/storage_image"
        android:layout_toEndOf="@+id/storage_image"
        android:layout_marginStart="25dp"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Total"
    android:id="@+id/total"
    android:layout_marginTop="20dp"
    android:layout_below="@+id/storage"
    android:layout_alignStart="@+id/storage"/>

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="11.64 MB"
        android:id="@+id/totalsize"
        android:layout_marginTop="5dp"
        android:layout_below="@+id/total"
        android:layout_alignStart="@+id/total"/>

<View
android:layout_width="250dp"
android:layout_height="10dp"
android:layout_marginTop="10dp"
android:id="@+id/progress"
android:layout_below="@+id/totalsize"
android:layout_alignStart="@+id/totalsize"
android:background="@android:color/darker_gray"/>
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="App"
        android:id="@+id/app"
        android:layout_marginTop="5dp"
        android:layout_below="@+id/progress"
        android:layout_alignStart="@+id/progress"/>
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Data"
        android:id="@+id/data"
        android:layout_marginTop="5dp"
        android:layout_below="@+id/progress"
        android:layout_toEndOf="@+id/app"
        android:layout_marginStart="160dp"/>
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="9.40 MB"
        android:id="@+id/app_value"
        android:layout_marginTop="5dp"
        android:layout_below="@+id/app"
        android:layout_alignStart="@+id/app"/>
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="2.24 MB"
        android:id="@+id/data_value"
        android:layout_marginTop="5dp"
        android:layout_below="@+id/data"
        android:layout_alignStart="@+id/data"/>

<Button
        android:layout_width="130dp"
        android:layout_height="35dp"
        android:text="CLEAR DATA"
        android:stateListAnimator="@drawable/button_elevation"
        android:background="@color/text_primary"
        android:id="@+id/clear"
        android:layout_marginTop="10dp"
        android:layout_below="@+id/app_value"
        android:layout_alignStart="@+id/app_value"/>

<View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_marginTop="12dp"
        android:id="@+id/last_divider"
        android:layout_below="@+id/clear"
        android:background="@android:color/darker_gray"/>

<ImageView android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginTop="10dp"
           android:id="@+id/usage"
           android:src="@drawable/hosting"
           android:layout_below="@+id/last_divider"
           android:paddingStart="16dp"
           android:paddingEnd="2dp"/>

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Data usage"
        android:id="@+id/data_usage"
        android:layout_alignTop="@+id/usage"
        android:layout_toEndOf="@+id/usage"
        android:layout_marginStart="25dp"/>

我应该使用一些线性布局并尝试嵌套它们吗?
最佳做法是什么

嵌套越少越好,因此,如果这能满足您的需要,这就是最佳做法。请注意,如果您将图像作为复合可绘制文件包含到TextView中,则即使ImageView也可能会被丢弃。