@ style/PreferenceThemeOverlay的PreferenceFragmentCompat填充问题 [英] PreferenceFragmentCompat padding issue with @style/PreferenceThemeOverlay

查看:579
本文介绍了@ style/PreferenceThemeOverlay的PreferenceFragmentCompat填充问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然使用preference-v7支持库(版本23.1.0)中的默认PreferenceThemeOverlay,但遇到了以下问题.从API 22开始,我的PreferenceFragmentCompat在我的偏好列表的左侧和右侧添加了一个难看的附加填充.

While using the default PreferenceThemeOverlay from the preference-v7 support library (version 23.1.0) I ran into the following issue. Starting from API 22 my PreferenceFragmentCompat had an ugly additional padding added to the left and right side of my preference list.

build.gradle:

build.gradle:

compile 'com.android.support:appcompat-v7:23.1.0'

styles.xml:

styles.xml:

<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>

在stackoverflow上找不到任何有用的解决方案之后,我自己写了一个解决方法.我只是想和你们分享.

After I didn't find any helpful solution on stackoverflow I wrote a workaround myself. I just wanted to share with u guys.

推荐答案

似乎API的dafault填充在其中< 22个设备,但不应出现在API> = 22中.这是我的解决方法:

It seems the dafault padding is there for API < 22 devices but should not be present in API >= 22. Here is my fix:

这进入styles.xml

This goes into styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light">

    ...

    <item name="preferenceTheme">@style/AppTheme.FixForPreferenceThemeOverlay</item>
</style>

<style name="AppTheme.FixForPreferenceThemeOverlay" parent="PreferenceThemeOverlay">
    <item name="preferenceFragmentListStyle">@style/AppTheme.FixForPreferenceFragmentList</item>
</style>
<style name="AppTheme.FixForPreferenceFragmentList">
    <item name="android:paddingLeft">0dp</item>
    <item name="android:paddingRight">0dp</item>
</style>

这篇关于@ style/PreferenceThemeOverlay的PreferenceFragmentCompat填充问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆