Android 通过使用设置片段,操作栏覆盖了首选项

Android 通过使用设置片段,操作栏覆盖了首选项,android,settings,preferences,Android,Settings,Preferences,我有一个简单的应用程序,带有一个以片段样式实现的单页首选项。我在安卓4.x(几个版本)的平板电脑上运行。当我打开首选项页面时,操作栏会覆盖最上面的首选项。我的工作是先做一个虚拟物品,但这当然是愚蠢的。我只是不知道如何保持动作栏,让首选项从动作栏下面开始。我不是在为动作栏编程,它只是出现了 Preferences.xml: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http:/

我有一个简单的应用程序,带有一个以片段样式实现的单页首选项。我在安卓4.x(几个版本)的平板电脑上运行。当我打开首选项页面时,操作栏会覆盖最上面的首选项。我的工作是先做一个虚拟物品,但这当然是愚蠢的。我只是不知道如何保持动作栏,让首选项从动作栏下面开始。我不是在为动作栏编程,它只是出现了

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


有什么建议吗?

通常你的
操作栏不应该覆盖内容。检查您是否为您的窗口设置了
窗口。功能\u操作\u栏\u覆盖
,即

requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
。。。在您的活动中被称为。如果是,请将其移除


希望这有助于。。。干杯

通过将这两个属性添加到styles.xml中,我的问题就解决了

<!-- Make setting content not covering by actionbar -->
<item name="android:fitsSystemWindows">true</item>
<item name="android:clipToPadding">true</item>

真的
真的

我的解决方案是将
app:layou behavior
属性添加到布局文件中
首选项片段的
容器中

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

如果有人遇到这个问题:我在带有design library应用程序栏的
4.4
5.0
手机上遇到了这个问题。尝试了上述解决方案,但没有结果。所做的工作是将我的片段的托管活动更改为
LinearLayout
,从而解决了问题