My application has user preferences with a custom layout, and after trying my application on Android 5, I noticed that my user settings look different (font size, color, padding) than others. So I thought it would be a simple fix, just taking the preference.xml from the android 5 SDK SDK, merging with my changes and putting the new layout in the layout-v21 . He fixed fill and color problems, but not the size of the header, which is larger.
My custom preference constructor looks like this:
public SeekBarPreference(Context context, AttributeSet attrs) { super(context, attrs); setLayoutResource(R.layout.preference_seekbar); }
preference_seekbar.xml (just added by Seekbar to the original layout):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:paddingEnd="?android:attr/scrollbarSize" android:background="?android:attr/selectableItemBackground" > <ImageView android:id="@+android:id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="15dip" android:layout_marginEnd="6dip" android:layout_marginTop="6dip" android:layout_marginBottom="6dip" android:layout_weight="1"> <TextView android:id="@+android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceLarge" android:ellipsize="marquee" android:fadingEdge="horizontal" /> <TextView android:id="@+android:id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@android:id/title" android:layout_alignStart="@android:id/title" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorSecondary" android:maxLines="4" /> <SeekBar android:id="@+id/seekbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+android:id/title" android:layout_toEndOf="@android:id/summary" android:layout_toStartOf="@android:id/widget_frame"/> </RelativeLayout> <LinearLayout android:id="@android:id/widget_frame" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="vertical" /> </LinearLayout>
You may notice that this header widget has this original attribute: android:textAppearance="?android:attr/textAppearanceLarge" , which should make the font large, but the question arises why the font size of the standard font is smaller if it uses the same layout ( only without a search box)?
source share