Android RelativeLayout проблема - PullRequest
       0

Android RelativeLayout проблема

0 голосов
/ 17 февраля 2011

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

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <RelativeLayout
    android:id="@+id/relativeTop"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <!--Buttons-->
  </RelativeLayout>
  <ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content">
      <!--Lots of nested RelatiLayouts with Views-->
    </RelativeLayout> 
  </ScrollView>
</RelativeLayout>

1 Ответ

1 голос
/ 18 февраля 2011

Для этого нужно знать атрибут xml android:layout_below

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <RelativeLayout
    android:id="@+id/relativeTop"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <!--Buttons-->
  </RelativeLayout>
  <ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/relativeTop"> <!-- here it goes! -->
    <RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content">
      <!--Lots of nested RelatiLayouts with Views-->
    </RelativeLayout> 
  </ScrollView>
</RelativeLayout>

Альтернативой является LinearLayout, который отлично работает для макетов, поскольку он может «разделить» ваш макет на две части ...

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