Представления RelativeLayout перекрываются - PullRequest
3 голосов
/ 02 марта 2012

Требуемый макет представляет собой заголовок с двумя кадрами ниже (чтобы содержать фрагменты позже) и фиксированными кнопками внизу экрана:

     Header Text     
----------------------
frame 1   |  frame 2
----------------------
btn 1   btn 2   btn 3

У меня в значительной степени это отсортировано (xml в конце),с одной проблемой ... два кадра перекрывают кнопки.

Я провел некоторый поиск по этой проблеме и нашел этот , но все, что он делает, это меняет мою проблему с кадровПереполнение кнопок к рамкам, переполняющим заголовок.

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

текущий макет xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView
            android:id="@+id/fdname"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:clickable="true"
            android:gravity="center"
            android:text="No department info has been entered yet"
            android:textSize="25dp" />
    <TextView
            android:id="@+id/fdaddress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/fdname"
            android:gravity="center"
            android:text="address"
            android:textSize="15dp" />
    <TextView
            android:id="@+id/horizontalline"
            android:layout_width="match_parent"
            android:layout_height="2dip"
            android:layout_below="@id/fdaddress"
            android:background="#ff23cf"
            android:gravity="center_vertical"
            android:paddingBottom="2dip"
            android:paddingTop="2dip" />
    <LinearLayout
            android:id="@+id/frames"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/horizontalline"
            android:orientation="horizontal" >
            <FrameLayout
                    android:id="@+id/leftpane"
                    android:layout_width="0px"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />
            <TextView
                    android:id="@+id/verticalline"
                    android:layout_width="2dp"
                    android:layout_height="match_parent"
                    android:background="#ff23cf"
                    android:gravity="center_horizontal"
                    android:paddingLeft="5dip"
                    android:paddingRight="5dip" />
            <FrameLayout
                    android:id="@+id/rightpane"
                    android:layout_width="0px"
                    android:layout_height="match_parent"
                    android:layout_weight="1" >
            </FrameLayout>
    </LinearLayout>
    <LinearLayout
            android:id="@+id/buttons"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:gravity="center"
            android:orientation="horizontal" >
            <Button
                    android:id="@+id/EventViewButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:minHeight="25dp"
                    android:text="@string/menu_event_view"
                    android:textSize="15dp" 
                    android:layout_weight="1">
            </Button>
            <Button
                    android:id="@+id/MemberViewButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:minHeight="25dp"
                    android:text="@string/menu_member_view"
                    android:textSize="15dp" 
                    android:layout_weight="1">
            </Button>
            <Button
                    android:id="@+id/AttendanceViewButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:minHeight="25dp"
                    android:text="@string/menu_atnd_view"
                    android:textSize="15dp" 
                    android:layout_weight="1">
            </Button>
    </LinearLayout>
</RelativeLayout>

Ответы [ 3 ]

4 голосов
/ 02 марта 2012

Попробуйте объявить LinearLayout, содержащий ваши кнопки, перед LinearLayout, содержащим ваши фреймы, сохранив атрибут android:layout_alignParentBottom="true".

Затем в контейнер фреймов добавьте ограничение above:1007 *

android:layout_below="@id/horizontalline"
android:layout_above="@id/buttons"

Этот способ должен заставить ваши кадры отображаться на экране последним, что заполняет оставшееся пространство.

Надеюсь, это сработает!

0 голосов
/ 03 марта 2012
<LinearLayout             
    android:id="@+id/frames"             
    android:layout_width="match_parent"             
    android:layout_height="match_parent"             
    android:layout_below="@id/horizontalline"             
    android:orientation="horizontal" > 

Почему ваш layout_height = "match_parent"? Вам нужно будет указать некоторую высоту или wrap_content.

0 голосов
/ 02 марта 2012

http://developer.android.com/resources/samples/ApiDemos/res/layout/relative_layout_1.html

Обратитесь к этому для верхнего слоя / выравнивания трех видов. (Пример трех текстовых видов)

Затем используйте линейное расположение с горизонтальной ориентацией для двух кадров,и то же самое для кнопок

-

, поэтому в основном к идентификатору frames добавьте alignbottom true и укажите

android:layout_above
android:layout_below

параметры

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...