2012-04-07 3 views
0

У меня есть RelativeLayout с тремя дочерними макетами. Информация о клиенте в верхнем макете (выровняйте родительский верх), три кнопки в центре макета и баннер в нижней макете (выровняйте нижнюю часть родителя).Расположение Android - расположение макетов

Я заполняю снизу вверх, чтобы получить нижний баннер для правильного выравнивания.

Проблема заключается в том, что макет центра отображается правильно. Моя верхняя компоновка вытесняет центральную компоновку вниз, и если я отключу 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> 
+1

Вы можете разместить изображение нужной планировки. Просто для и Идея, как вы хотите свой макет. –

+0

Получил это. Мне просто нужно было сделать компоновку центра последней. Спасибо, в любом случае. – user1222760

ответ

0

Получил его. Мне просто нужно было сделать компоновку центра последней.

Thanks

0

использовать следующий модифицированный 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> 
Смежные вопросы