ScrollView for only a portion of the Screen
I'm having some trouble dividing my screen up in to two parts. I don't know where to begin actually. All of my layouts thus far have been using RelativeLayout. Basically, I want to have a scrollable view in the top 70%(or so) of the screen, and two buttons in the bottom 30%(or so) of the screen. The scrollview would be filled with several textViews. Here's my barebone code:
<?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>
<Butto开发者_StackOverflown
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>
If you want percentages, the easiest way is to use a LinearLayout
and weights. Something like:
<LinearLayout android:orientation="vertical" ...>
<ScrollView android:layout_weight="7" ... />
<RelativeLayout android:layout_weight="3" ...>
<Button ... />
<Button ... />
</RelativeLayout>
</LinearLayout>
精彩评论