I have a custom dialog with a layout like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/mylayout"> <LinearLayout android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView ... /> <TextView .../> </LinearLayout> <ScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/title"> <LinearLayout ...> <TextView ... android:text="lots of text........" /> <TextView .../> </LinearLayout> </ScrollView <RelativeLayout ... android:layout_below="@+id/scrollView"> <Button ...> <Button ...> </RelativeLayout> </RelativeLayout>
My problem is that scrollview is that with too much text in scrollview, the buttons at the bottom are pushed out of the dialog box. I was able to prevent this by binding a RelativeLayout, which contains the buttons at the bottom, using android: layout_alignParentBottom = "true", but I stretch the entire dialog at the bottom of the screen when there is less text in scrollview and I don't want this.
How can I get such a layout:
[SOME TEXT] [Scrollable region] [Buttons]
Charles Ma
source share