我有一个简单的应用程序,其中包含以 fragment 样式实现的单页首选项。我在装有 Android 4.x(多个版本)的平板电脑上运行。当我打开首选项页面时,操作栏会覆盖最上面的首选项。我的解决方法是有一个虚拟的第一项,但这当然是愚蠢的。我只是不知道如何保留操作栏并让首选项从操作栏下方开始。我不是为操作栏编程,它只是显示出来。
首选项.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference
android:key="pref_AdaptToRoomXXX"
android:title="This is the dummy item as a spacer" />
<CheckBoxPreference
android:key ="@string/pref_TimeFormat"
android:title ="@string/action_setTimeFormat"
android:summary ="@string/action_setTimeFormat"
/>
<ListPreference
android:key="@string/pref_DateFormat"
android:title="@string/action_setDateFormat"
android:summary="@string/action_setDateFormat"
android:dialogTitle="@string/action_setDateFormat"
android:entries="@array/action_setDateFormat_options"
android:entryValues="@array/action_setDateFormat_values"
android:defaultValue="@string/action_setDateFormat_default" />
<ListPreference
android:key="@string/pref_TextColor"
android:title="@string/action_setTextColor"
android:summary="@string/action_setTextColor"
android:dialogTitle="@string/action_setTextColor"
android:entries="@array/action_setTextColor_colors"
android:entryValues="@array/action_setTextColor_values"
android:defaultValue="@string/action_setTextColor_default" />
<CheckBoxPreference
android:key="@string/pref_DimOnBattery"
android:title="@string/action_setDimOnBattery"
android:defaultValue="true" />
</PreferenceScreen>
有什么建议吗?
最佳答案
通常您的 ActionBar
不应覆盖内容。检查您是否为窗口设置了 Window.FEATURE_ACTION_BAR_OVERLAY
,即 ...
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
... 在您的 Activity 中调用。如果是这样 - 将其删除。
希望这有帮助...干杯!
关于android - 使用设置 fragment ,操作栏覆盖顶部首选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16574233/