2013-07-31 45 views
0

在Android中,我有一個首選項屏幕(請參閱第一個屏幕快照)。用戶點擊「選擇球」並顯示子屏幕(見第二個屏幕截圖)。但是,第一個屏幕仍然顯示在第二個屏幕的下方,例如當顯示子屏幕時,您可以看到「選擇球」。我如何防止這種情況?Android首選項屏幕出現在子屏幕下

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > 
    android:title="@string/livewallpaper_settings"> 

    <PreferenceScreen 
     android:key="ball_color_category_key" 
     android:persistent="false" 
     android:title="@string/ballcolor" > 

     <PreferenceCategory android:title="@string/livewallpaper_settings" > 
      <CheckBoxPreference 
       android:defaultValue="true" 
       android:key="redball" 
       android:summary="Display red ball." 
       android:title="Display red ball" /> 
      <CheckBoxPreference 
       android:defaultValue="true" 
       android:key="greenball" 
       android:summary="Display green ball." 
       android:title="Display green ball" /> 
      <CheckBoxPreference 
       android:defaultValue="true" 
       android:key="blueball" 
       android:summary="Display blue ball." 
       android:title="Display blue ball" /> 
      <CheckBoxPreference 
       android:defaultValue="true" 
       android:key="yellowball" 
       android:summary="Display yellow ball." 
       android:title="Display yellow ball" /> 
      <CheckBoxPreference 
       android:defaultValue="true" 
       android:key="purpleball" 
       android:summary="Display purple ball." 
       android:title="Display purple ball" /> 
     </PreferenceCategory> 
    </PreferenceScreen> 

    <PreferenceCategory android:title="@string/livewallpaper_settings" > 
     <Preference 
      android:key="facebook" 
      android:summary="@string/facebook" 
      android:title="@string/facebook" /> 
    </PreferenceCategory> 

</PreferenceScreen> 

First screen

Second screen

+0

什麼是您使用的窗口背景活動?它是透明的嗎? – Karakuri

+0

根據您的意見,我一直在尋找這樣的參數。我試過 'android:windowIsTranslucent =「false」' 'android:windowBackground =「@ color/orange」' (其中orange在res/values/strings.xml中定義),但沒有效果。我也嘗試了一個主題,正如這裏所建議的,但沒有效果: http://stackoverflow.com/questions/3551169/change-background-color-of-preference 但也沒有效果。 –

+0

如果我在LiveWallpaperSetting.java中執行此操作: 'ListView listView = this.getListView();' 'listView.setBackgroundColor(Color.BLUE);' 然後頂層首選項屏幕的背景顏色是藍色且不透明的,但這對子屏幕沒有影響。 –

回答

0

對我來說,解決辦法是設置主題在manifest.xml文件的活動:

<activity android:label="@string/livewallpaper_settings" 
    android:name="com.developername.LiveWallpaperSettings" 
    android:exported="true" 
    android:icon="@drawable/ic_launcher" 
    android:theme="@android:style/Theme.Black"> 
</activity>`