Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.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,我有一个有三个子布局的RelativeLayout。顶部布局中的客户信息(对齐父级顶部),中间布局中的三个按钮和底部布局中的横幅(对齐父级底部) 我从下往上填充,以使底部横幅与底部正确对齐 问题是如何正确显示中心布局。我的顶部布局是强制中心布局向下,如果我禁用1或2个中心按钮(消失),我需要它们浮动到布局顶部。我可以得到我需要正确显示的变化,但不是所有的东西都放对了 任何帮助都将不胜感激。谢谢 <?xml version="1.0" encoding="utf-8"?> <Re

我有一个有三个子布局的RelativeLayout。顶部布局中的客户信息(对齐父级顶部),中间布局中的三个按钮和底部布局中的横幅(对齐父级底部)

我从下往上填充,以使底部横幅与底部正确对齐

问题是如何正确显示中心布局。我的顶部布局是强制中心布局向下,如果我禁用1或2个中心按钮(消失),我需要它们浮动到布局顶部。我可以得到我需要正确显示的变化,但不是所有的东西都放对了

任何帮助都将不胜感激。谢谢

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/adLayout"
    android:background="@drawable/ad_contact_background"
    android:layout_height="fill_parent"
    android:layout_width="match_parent"
    android:orientation="horizontal" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/linearLayoutAd"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true" >

        <ImageView
            android:id="@+android:id/ad_contactAdImageView"
            android:layout_height="wrap_content" 
            android:layout_width="match_parent" />

    </LinearLayout>

    <RelativeLayout 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/relativeLayoutContact"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_above="@+id/linearLayoutAd" >

        <Button
            android:id="@+id/ad_contactWebsiteButton"
            android:background="@drawable/button_black"
            android:layout_height="50dp"
            android:layout_width="match_parent"
            android:layout_marginTop="10dip"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:textSize="18dip"
            android:textStyle="bold"
            android:textColor="@android:color/white" 
            android:typeface="sans" />

        <Button
            android:id="@+id/ad_contactEmailButton"
            android:background="@drawable/button_black"
            android:layout_height="50dp"
            android:layout_width="match_parent"
            android:layout_marginTop="10dip"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:textSize="18dip"
            android:textStyle="bold"
            android:textColor="@android:color/white" 
            android:typeface="sans" />

        <Button
            android:id="@+id/ad_contactPhoneButton"
            android:background="@drawable/button_black"
            android:layout_height="50dp"
            android:layout_width="match_parent"
            android:layout_marginTop="10dip"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_marginBottom="20dip"
            android:textSize="18dip"
            android:textStyle="bold"
            android:textColor="@android:color/white" 
            android:typeface="sans" />

    </RelativeLayout>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/linearLayoutTitle"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_above="@+id/relativeLayoutContact"
        android:layout_alignParentTop="true" >

        <TextView
            android:id="@+id/ad_contactTitleTextView"
            android:cacheColorHint="#00000000"
            android:gravity="center"
            android:layout_height="wrap_content" 
            android:layout_width="match_parent"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:layout_marginTop="20dip"
            android:textColor="#000000"
            android:textSize="24dip"
            android:textStyle="bold"
            android:typeface="sans" />

        <TextView
            android:id="@+id/ad_contactAddressTextView"
            android:cacheColorHint="#00000000"
            android:gravity="center"
            android:layout_height="wrap_content" 
            android:layout_width="match_parent"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:textColor="#000000"
            android:textSize="20dip"
            android:typeface="sans" />

    </LinearLayout>

</RelativeLayout>

使用下面修改的xml文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/adLayout"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/linearLayoutTitle"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
       android:layout_alignParentTop="true">

        <TextView
            android:id="@+id/ad_contactTitleTextView"
            android:cacheColorHint="#00000000"
            android:gravity="center"
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:layout_marginTop="20dip"
            android:textColor="#000000"
            android:textSize="24dip"
            android:textStyle="bold"
            android:typeface="sans" />

        <TextView
            android:id="@+id/ad_contactAddressTextView"
            android:cacheColorHint="#00000000"
            android:gravity="center"
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:textColor="#000000"
            android:textSize="20dip"
            android:typeface="sans" />

    </LinearLayout>



    <LinearLayout
        android:id="@+id/relativeLayoutContact"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/linearLayoutTitle"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/ad_contactWebsiteButton"
            android:background="@drawable/ic_launcher"
            android:layout_height="50dp"
            android:layout_width="wrap_content"
            android:layout_marginTop="10dip"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:textSize="18dip"
            android:textStyle="bold"
            android:textColor="@android:color/white" 
            android:typeface="sans" />

        <Button
            android:id="@+id/ad_contactEmailButton"
            android:background="@drawable/ic_launcher"
            android:layout_height="50dp"
            android:layout_width="wrap_content"
            android:layout_marginTop="10dip"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:textSize="18dip"
            android:textStyle="bold"
            android:textColor="@android:color/white" 
            android:typeface="sans" />

        <Button
            android:id="@+id/ad_contactPhoneButton"
            android:background="@drawable/ic_launcher"
            android:layout_height="50dp"
            android:layout_width="wrap_content"
            android:layout_marginTop="10dip"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_marginBottom="20dip"
            android:textSize="18dip"
            android:textStyle="bold"
            android:textColor="@android:color/white" 
            android:typeface="sans" />

    </LinearLayout>

    <ImageView
        android:id="@+android:id/ad_contactAdImageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" 
        android:layout_alignParentBottom="true"/>
</RelativeLayout>


明白了。我只需要最后渲染中心布局


谢谢

您可以发布所需布局的图像吗。只是为了你的想法,你想要怎样的布局,明白了。我只需要最后渲染中心布局。无论如何,谢谢你。