Android 在首选项列表底部截断的自定义首选项类别

Android 在首选项列表底部截断的自定义首选项类别,android,preferences,Android,Preferences,我从PreferenceCategory扩展,因此可以将其文本颜色更改为红色(请参见屏幕截图)。但事实证明,最后一个首选项字段不再显示,它在底部被截断。我用红色指示了应显示首选项的位置 正如您在我的实现中看到的,我没有覆盖任何其他内容: public class PreferenceCategoryDangerZone extends PreferenceCategory { public PreferenceCategoryDangerZone(Context context) {

我从
PreferenceCategory
扩展,因此可以将其文本颜色更改为红色(请参见屏幕截图)。但事实证明,最后一个首选项字段不再显示,它在底部被截断。我用红色指示了应显示首选项的位置

正如您在我的实现中看到的,我没有覆盖任何其他内容:

public class PreferenceCategoryDangerZone extends PreferenceCategory {

    public PreferenceCategoryDangerZone(Context context) {
        super(context);
    }

    public PreferenceCategoryDangerZone(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PreferenceCategoryDangerZone(Context context, AttributeSet attrs,
                            int defStyle) {
        super(context, attrs, defStyle);
    }

    // Tried both with and without this constructor, but same result
    @TargetApi(21)
    public PreferenceCategoryDangerZone(Context context, AttributeSet attrs,
                                    int defStyle, int defStyleRes) {
        super(context, attrs, defStyle, defStyleRes);
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
        TextView titleView = (TextView) view.findViewById(android.R.id.title);
        titleView.setTextColor(getContext().getResources().getColor(R.color.red));
    }
}
XML:


...
当我使用默认的
PreferenceCategory
时,它工作得非常好。我试图在
PreferenceCategoryDangerZone
下面添加一个
首选项。结果,整个类别显示正确,但新添加的最后一个元素仍然被切断


你知道哪里出了问题吗?谢谢。

显示xml文件并添加它。感谢您指出。PreferenceCategoryDangerZone是否继承自PreferenceCategory之类的特定内容?
公共类PreferenceCategoryDangerZone扩展了PreferenceCategory{…}
,所以是的。
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

    ...

    <com.mohoff.leapp.ui.components.settings.PreferenceCategoryDangerZone
        android:title="@string/setting_cat_danger_zone_title"
        android:key="@string/setting_cat_danger_zone">

        <Preference android:title="@string/setting_delete_timeslots_title"
                    android:key="@string/setting_delete_timeslots"/>
        <Preference android:title="@string/setting_delete_zones_title"
                    android:key="@string/setting_delete_zones"/>
        <Preference android:title="@string/setting_clean_map_title"
                    android:summary="@string/setting_clean_map_summary"
                    android:key="@string/setting_clean_map"/>
    </com.mohoff.leapp.ui.components.settings.PreferenceCategoryDangerZone>

</PreferenceScreen>