Aenadon Aenadon - 14 days ago 8
Android Question

Theme.AppCompat.Dialog theme creates empty (dead) space

In my application, I am using an Activity with the theme "Theme.AppCompat.Dialog" to display it as a dialog. That works out well, however, the dialog fills the entire screen height, leaving a lot of space empty. To illustrate my issue, here is a picture of opening the dialog (on an unusually high resolution to demonstrate the issue better):

enter image description here

The higher the resolution, the greater this space.

Here is a code snippet:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools">

<!--This is the yellow box-->
<LinearLayout
android:id="@+id/dialog_button_bar"
android:layout_alignParentBottom="true"
style="?android:buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
[Buttons...]
</LinearLayout>

<!--This is the red box-->
<ScrollView
android:layout_above="@id/dialog_button_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
[LinearLayout containing rows...]
</ScrollView>




If I remove the
android:layout_alignParentBottom="true"
and the
android:layout_above="@id/dialog_button_bar"
attributes, the whole layout jumps to the top and now the empty space is below my layout.

What am I doing wrong? :(

Answer

It seems like this is some kind of intended behavior. The standard Android app installation dialog seems to behave the same way (leaving a lot of blank space between the permission part and the buttons) so I guess I'll keep it this way...

Comments