0

I found this very useful site: http://android-journey.blogspot.de/2010/01/for-almost-any-application-we-need-to.html

It shows a custom seekbar preference implementation. My Problem is, that I have several listpreference items in my preferencescreen, and I also like to implement a seekbar pref. To do this, I have to extend the Preference class and provide a Layout which will be used in the listview of preferencescreen.

The problem is, the standard listpreferences have all the same layout height, and my seekbar pref has another height...but I'd like to have all prefs the same size (height) in the preferencescreen on different android versions (2.2 - 4.2). Also the text size and color differs a little.

Is there a way to get the standard android PreferenceActivity layout property values or any other solution for this?

CraigTeegarden
  • 8,173
  • 8
  • 38
  • 43
pawlinsky
  • 420
  • 1
  • 6
  • 18
  • Replace the code by xml layout and add `android:minHeight="?android:attr/listPreferredItemHeight"` to the root element. You can find the default layout of preferences in files like "android-sdk-windows\platforms\android-8\data\res\layout\preference.xml" – vortexwolf Jan 08 '13 at 20:58
  • Hi, thanks for your answer. And this does not work? Dont know why... linearLayoutSeekBar.setMinimumHeight(R.attr.listPreferredItemHeight); get an ex: 01-08 22:18:15.006: E/AndroidRuntime(374): java.lang.IllegalArgumentException: bitmap size exceeds 32bits – pawlinsky Jan 08 '13 at 21:19
  • Something like this, but I don't know the exact syntax: ` `TypedArray a = this.getApplication().getTheme().obtainStyledAttributes(android.R.styleable.Theme); int height = a.getInteger(R.styleable.Theme_listPreferredItemHeight, 0); linearLayoutSeekBar.setMinimumHeight(height)` – vortexwolf Jan 09 '13 at 05:32
  • i only find R.style.Theme, but thats just an int, and not an array. By the way, i copied the preference.xml from the layout folder. So this works fine on android < 4.0. But since 4.0 there is also an Holo theme included, an this is an special preference_holo.xml with other layout properties...when i copy this i get an error: no resource found that matches the given name @dimen/preference_item_padding_inner... So...i think i have to make an ListActivity with my custom items...and save the values manually...Or i just take a listpreference... – pawlinsky Jan 09 '13 at 12:37

0 Answers0