3

我有一个简单的应用程序,它具有以片段样式实现的单页首选项。我在装有 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>

有什么建议么?

4

4 回答 4

3

通常你ActionBar不应该覆盖内容。检查您是否已Window.FEATURE_ACTION_BAR_OVERLAY为您的窗口设置,即...

requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

... 在您的活动中被调用。如果是这样 - 删除它。

希望这会有所帮助......干杯!

于 2013-05-15T20:31:08.090 回答
1

我的解决方案是将app:layout_behavior属性添加到布局文件中的<FrameLayout />容器中。PreferenceFragment

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />
于 2016-02-12T23:47:46.733 回答
0

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

<!-- Make setting content not covering by actionbar -->
<item name="android:fitsSystemWindows">true</item>
<item name="android:clipToPadding">true</item>
于 2014-08-22T07:03:05.783 回答
0

万一有人遇到这个问题:我在带有设计库应用栏的手机上4.4发生了这种情况。5.0尝试了上述解决方案无济于事。起作用的是将我的片段的托管活动更改为LinearLayout,解决了问题。

于 2016-02-19T00:40:54.867 回答