PreferenceScreen android:paddingTop not working -
with normal layout file, can set padding top this
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingtop="?attr/actionbarsize" > however, preference screen, renders padding short of pixels (the action bar 168 dp, padding appears 144), idea how fix cross-device way. thanks.
<preferencescreen xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingtop="?attr/actionbarsize">
when using preferencescreen don't have access xml attributes. can add attribute it:
android:layout="@layout/header_setting" then create xml layout file called in example "header_settings" can change sizes , padding normal. applying id's elements preferencescreen knows titles goes or icon.
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:padding="0dp" android:layout_height="match_parent"> <imageview android:id="@+android:id/icon" android:layout_marginleft="@dimen/activity_horizontal_margin" android:layout_margintop="15dp" android:layout_marginbottom="15dp" android:layout_width="40dp" android:layout_height="40dp" /> <textview android:id="@+android:id/title" android:layout_marginleft="80dp" android:textcolor="#000" android:layout_margintop="23dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="18sp"/> </linearlayout> and here example on how preferencescreen should like:
<?xml version="1.0" encoding="utf-8"?> <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android" android:layout="@layout/pref_screen"> <preferencecategory> <preferencescreen android:icon="@drawable/setting_star" android:layout="@layout/header_setting" android:title="upgrade pro!"> </preferencescreen> </preferencecategory> </preferencescreen> notice how have access attributes: title, summary, , icon. layout attribute lets customize whatever want do. in xml must keep id's same since thats how preferencescreen knows thats put title text or icon image.
i hope helps!
Comments
Post a Comment