ScrollView только для части экрана - PullRequest
0 голосов
/ 06 октября 2011

У меня проблемы с разделением экрана на две части.Я не знаю, с чего начать на самом деле.До сих пор все мои макеты использовали RelativeLayout.По сути, я хочу иметь прокручиваемый вид в верхних 70% (или около того) экрана и две кнопки в нижних 30% (или около того) экрана.Scrollview будет заполнен несколькими textViews.Вот мой базовый код:

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/stonerepeat"
android:gravity="center_horizontal"
>








<Button
android:id="@+id/back"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Looks good"
android:layout_alignParentBottom="true" 
android:layout_alignParentLeft="true" 
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" 
android:layout_marginBottom="10dp"
>
</Button>
<Button
android:id="@+id/stats"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hero Stats"
android:layout_alignLeft="@+id/back"
android:layout_alignRight="@+id/back" 
android:layout_above="@+id/back"
android:layout_marginBottom="3dp"
>
</Button>


</RelativeLayout>

1 Ответ

1 голос
/ 06 октября 2011

Если вам нужны проценты, самый простой способ - использовать LinearLayout и веса. Что-то вроде:

<LinearLayout android:orientation="vertical" ...>
    <ScrollView android:layout_weight="7" ... />
    <RelativeLayout android:layout_weight="3" ...>
        <Button ... />
        <Button ... />
    </RelativeLayout>
</LinearLayout>
...