android-在自定义首选项中使用默认首选项高度

android-在自定义首选项中使用默认首选项高度,android,height,android-preferences,preferenceactivity,preference,Android,Height,Android Preferences,Preferenceactivity,Preference,我有一个自定义偏好: public class ButtonPreference extends Preference { public ButtonPreference(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ButtonPreference(Context context, Attrib

我有一个自定义偏好:

public class ButtonPreference extends Preference {
    public ButtonPreference(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

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

    @Override
    protected View onCreateView(ViewGroup parent) {
        super.onCreateView(parent);
        LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        return li.inflate(R.layout.button_prederence, parent, false);
    }

}
和xml
按钮\u prederence.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Click me" />

</LinearLayout>

我希望我所有的首选项都处于相同的高度,因此我需要获得默认的首选项高度,并将其应用于
按钮引用


我该怎么做呢?

我也有这个问题

经过一些研究,我发现了这种变通方法。尝试在
线性布局中添加此行

android:minHeight=“?android:listPreferredItemHeight”
或者您可以在
sdk\platforms\android-24\data\res\layout\preferences.xml