0

에 사용되는 기본 환경 설정 높이 나는 사용자 정의 기본 설정이 있습니다안드로이드 사용자 환경

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); 
    } 

} 

및 XMLbutton_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> 

, 그래서 기본 환경 설정 높이를 받아서 ButtonPreference에 적용해야합니다.

어떻게하면됩니까?

답변

0

이 문제도 발생합니다.

몇 가지 조사를 한 후에이 해결 방법을 발견했습니다. LinearLayout에이 줄을 추가하십시오.

android:minHeight="?android:listPreferredItemHeight" 

하거나
sdk\platforms\android-24\data\res\layout\preferences.xml

Preference의 원본 XML 파일을 확인할 수 있습니다