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

Android 在两个相对布局之间应用填充

Android 在两个相对布局之间应用填充,android,Android,我试图通过在两个布局之间放置填充来显示两个相对布局,以便 圆角布局将在连接处可见,显示布局重叠。那么如何在它们之间设置间距 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="matc

我试图通过在两个布局之间放置填充来显示两个相对布局,以便 圆角布局将在连接处可见,显示布局重叠。那么如何在它们之间设置间距

     <?xml version="1.0" encoding="utf-8"?>


        <RelativeLayout 
           xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"  
            android:layout_height="match_parent"
            android:background="@drawable/background" >


            <RelativeLayout
                android:id="@+id/relativeLayout1"  android:layout_width="match_parent"
                android:layout_height="fill_parent"   android:paddingTop="22dp"     
                android:paddingLeft="20dp"      android:paddingRight="20dp"   android:paddingBottom="20dp"          
                >


                <RelativeLayout
                    android:id="@+id/create" android:paddingTop="10dp" android:paddingBottom="15dp"
                    android:layout_width="match_parent" android:paddingLeft="10dp" android:paddingRight="10dp"
                    android:layout_height="wrap_content"  android:background="@drawable/rounded_corner"         
                    >


                     <RelativeLayout
                    android:id="@+id/phone"   android:layout_width="match_parent"
                    android:layout_height="wrap_content"    android:layout_below="@+id/last"
                    android:background="#ffffff" >

                    <ImageView
                        android:id="@+id/icon"      android:paddingRight="10dp"
                        android:layout_width="wrap_content"       android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"      android:src="@drawableicon" />

                    <EditText
                        android:id="@+id/Phonenumber"  android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_toRightOf="@+id/icon"
                        android:hint="Enter Phone Number" />
                </RelativeLayout>



           </RelativeLayout>


                <RelativeLayout
                    android:id="@+id/contactAddress"    android:layout_width="match_parent"
                    android:layout_height="wrap_content"  android:layout_below="@+id/create"   android:paddingLeft="10dp"      
                    android:paddingBottom="20dp" android:background="@drawable/rounded_corner"  android:paddingTop="20dp" >



                    <RelativeLayout
                    android:id="@+id/state" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/city"
                    android:background="#ffffff" >

                    <ImageView
                        android:id="@+id/stateicon"  android:paddingRight="10dp"
                        android:layout_width="wrap_content"  android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true" android:src="@drawable/stateicon" />

                    <EditText
                        android:id="@+id/enterstate"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_toRightOf="@+id/stateicon"
                        android:hint="Enter State" />
                </RelativeLayout>





                </RelativeLayout>



               </RelativeLayout> 


            </RelativeLayout>




<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"  
    android:layout_height="match_parent"
    android:background="@drawable/background" >


    <RelativeLayout
        android:id="@+id/relativeLayout1"  android:layout_width="match_parent"
        android:layout_height="fill_parent"   android:paddingTop="22dp"     
        android:paddingLeft="20dp"      android:paddingRight="20dp"   android:paddingBottom="20dp"          
        >


        <RelativeLayout
            android:id="@+id/create" android:paddingTop="10dp" android:paddingBottom="15dp"
            android:layout_width="match_parent" android:paddingLeft="10dp" android:paddingRight="10dp"
            android:layout_height="wrap_content"  android:background="@drawable/rounded_corner"         
            >


             <RelativeLayout
            android:id="@+id/phone"   android:layout_width="match_parent"
            android:layout_height="wrap_content"    android:layout_below="@+id/last"
            android:background="#ffffff" >

            <ImageView
                android:id="@+id/icon"      android:paddingRight="10dp"
                android:layout_width="wrap_content"       android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"      android:src="@drawableicon" />

            <EditText
                android:id="@+id/Phonenumber"  android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/icon"
                android:hint="Enter Phone Number" />
        </RelativeLayout>



   </RelativeLayout>


        <RelativeLayout
            android:id="@+id/contactAddress"    android:layout_width="match_parent"
            android:layout_height="wrap_content"  android:layout_below="@+id/create"   android:paddingLeft="10dp"      
            android:paddingBottom="20dp" android:background="@drawable/rounded_corner"  android:paddingTop="20dp" >



            <RelativeLayout
            android:id="@+id/state" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/city"
            android:background="#ffffff" >

            <ImageView
                android:id="@+id/stateicon"  android:paddingRight="10dp"
                android:layout_width="wrap_content"  android:layout_height="wrap_content"
                android:layout_alignParentLeft="true" android:src="@drawable/stateicon" />

            <EditText
                android:id="@+id/enterstate"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/stateicon"
                android:hint="Enter State" />
        </RelativeLayout>





        </RelativeLayout>



       </RelativeLayout> 






    </RelativeLayout>

此XML完全混乱

首先,您应该正确地缩进代码,使其更具可读性。这是一个很好的实践,如果你想在(严肃的)团队中工作,这是必要的

第二,你有太多的相对布局
RelativeLayout
是要渲染的“最重”布局。如果你想走这条不太好(真的是灾难性的)的路线,至少使用
FrameLayout
封装
state
phone
相关布局。如果填充不起作用,请尝试在内部元素上添加边距

第三,如果你想体面地做事,就要避免这种做法。为一个版面制作背景。。。圆角和所有