2016-11-02 20 views
0

在我的應用程序中,我使用的主題爲「Theme.AppCompat.Dialog」的Activity將其顯示爲對話框。這很好,但是,對話框填滿了整個屏幕高度,留下了很多空間。爲了說明我的問題,這裏是打開的對話框中(在一個非常高的分辨率來證明這個問題更好)的照片:Theme.AppCompat.Dialog主題創建空(死)空間

enter image description here

分辨率越高,越大這個空間。

下面的代碼片段:

<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> 

如果我刪除android:layout_alignParentBottom="true"android:layout_above="@id/dialog_button_bar"屬性,整個佈局跳轉到頂部,現在空的空間低於我的佈局。

我在做什麼錯? :(

回答

1

看起來這是一種預期的行爲,標準的Android應用程序安裝對話似乎行爲相同(在權限部分和按鈕之間留下大量空白),所以我想我會保持這種方式...

0

在AndroidManifest.xml中styles.xml創建新樣式現在

<style name="MyCustomDialog" parent="Base.Theme.AppCompat.Light.Dialog"> 
    <item name="android:windowNoTitle">true</item> 
    <item name="windowActionBar">false</item> 
</style> 

,添加機器人:主題= 「@風格/ MyCustomDialog」 你的對話活動

+0

沒有幫助 :( – Aenadon