Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulate android preference category look/feel

I like the title bar style from the Android preference category.

In my Activity (not a PreferenceActivity) How can I use the same style?

like image 926
Premier Avatar asked Jul 28 '10 05:07

Premier


2 Answers

Since I just spent the last few hours trying to answer this old question, I'll do it here for anyone else. It turns out the resource the preference category style is using is listSeparatorTextViewStyle.

You use it like this:

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, World"
style="?android:attr/listSeparatorTextViewStyle"/>

Using style="?android:attr/preferenceCategoryStyle" didn't work.

like image 135
Jems Avatar answered Oct 22 '22 15:10

Jems


The main layout is most likely a ScrollView with a LinearLayout. As for the individual layout, I believe (just guessing after looking at the documentation) that you can use the various attributes in android.R.attr - look here: http://developer.android.com/reference/android/R.attr.html. There are attributes like preferenceCategoryStyle, preferenceStyle, etc. You can apply any style to any of your views.

like image 37
EboMike Avatar answered Oct 22 '22 14:10

EboMike