Premier
Premier

Reputation: 4228

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?

Upvotes: 10

Views: 2933

Answers (2)

Jems
Jems

Reputation: 11620

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.

Upvotes: 20

EboMike
EboMike

Reputation: 77752

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.

Upvotes: 1

Related Questions