【问题标题】:Android Preferences screen appears underneath subscreenAndroid 首选项屏幕出现在子屏幕下方
【发布时间】:2013-08-01 09:12:48
【问题描述】:

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

【问题讨论】:

  • 您用于活动的窗口背景是什么?它完全透明吗?
  • 根据你的cmets,我一直在寻找这样的参数。我尝试了android:windowIsTranslucent="false" android:windowBackground="@color/orange"(其中橙色在 res/values/strings.xml 中定义),但没有效果。我也尝试了一个主题,按照这里的建议,但没有效果:stackoverflow.com/questions/3551169/… 但也没有效果。
  • 如果我在 LiveWallpaperSetting.java 中这样做:ListView listView = this.getListView(); listView.setBackgroundColor(Color.BLUE); 那么顶层首选项屏幕的背景颜色是蓝色和不透明的,但这对子屏幕没有影响。
  • 我的答案是在项目 manifest.xml 文件中设置主题

标签: android preferences


【解决方案1】:

我的解决方案是在 manifest.xml 文件中的 Activity 中设置主题:

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

【讨论】:

  • 如果我真的想使用透明背景,这并不能解决问题。现在子屏幕不一定需要是透明的,但更可取的行为是禁用主偏好屏幕的可见性......但是,从我的角度来看,完全禁用透明背景不是一个可接受的解决方案。
猜你喜欢
  • 1970-01-01
  • 2011-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多