Reputation: 6023
I have created a sample demo application for the custom Android preference using support library preference-v7
.
Code: https://github.com/saurabhkpatel/Android-Custom-Preference-Sample
I am facing two problems here:
In this demo application, I have total three different types of preferences. One is ListPreference
, Second is Custom Preference
which I have created and the last one is SwitchPreferenceCompat
. If I put Custom Preference
in between these two preferences categories then it's not working expected. Please check this attached screenshot. You can see that third SwitchPreferenceCompat
is missing.
Even I can see the seek bar twice which comes from custom layout file, but I have only one seek-bar over there.
Everything is working fine if I put SampleCustomPreference
at last.
Any ideas, Why this behavior is happening?
Thanks for your time.
Expected
Upvotes: 0
Views: 540
Reputation: 1070
The layout file layout_pref.xml has an issue. The height of the parent layout should be wrap content not match parent. Corrected xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/widget_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@android:id/title"
style="@android:style/TextAppearance.DeviceDefault.SearchResult.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C Title" />
<TextView
android:id="@android:id/summary"
style="@android:style/TextAppearance.DeviceDefault.SearchResult.Subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C Summary" />
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Upvotes: 1