PreferenceScreen的分隔线

时间:2018-11-02 14:28:23

标签: android androidx preferencescreen android-9.0-pie

在迁移到AndroidX并将目标SDK升级到28之后,我的SettingsPage失去了PreferenceScreen组件之间的分隔线,并且文本未对齐。有人可以帮忙吗?

`

<PreferenceScreen android:title="@string/dummy_string_1">
    <intent
        android:action="android.intent.action.VIEW"
        android:targetPackage="@string/app_package_name" />
</PreferenceScreen>

<PreferenceScreen android:title="@string/dummy_string_2">

    <intent
        android:action="android.intent.action.VIEW"
        android:targetPackage="@string/app_package_name" />

</PreferenceScreen>

<PreferenceScreen android:title="@string/dummy_string_3">

    <intent
        android:action="android.intent.action.VIEW"
        android:targetPackage="@string/app_package_name" />

</PreferenceScreen>

`

This is how it looks now, without dividers and text is not left aligned

1 个答案:

答案 0 :(得分:1)

使用分隔线创建自己的布局,然后添加以下标记:

android:layout="@layout/divider_preference"