Domanda

Simple question: What is the default value of android:dividerHeight for a normal listview? I bet you can probably look it up somewhere, but I wouldn't know where.

Thanks in advance!

È stato utile?

Soluzione

Both of the other answers are just partly right. The ListView_dividerHeight is stylable but Android itself doesn't set a default value (at least not the stock Android). If the app itself doesn't set the value like this e.g.:

<item name="android:dividerHeight">5dp</item>

then @android:drawable/divider_horizontal_dark_opaque will be used which exists in four different "flavors" (ldpi, mdpi, hdpi and xhdpi).

So the "real" answer is: there's no way to tell. It depends on:

  • Screen density
  • Android version
  • Customization by the manufacturer
  • App theming
  • possibly other factors

To find these answers yourself check out your Android SDK folder: platforms\android-17\data\res\values\attrs.xml / styles.xml / themes.xml (android-17 might be different for your installation) and read the documentation about themes & styles: http://developer.android.com/guide/topics/ui/themes.html

Altri suggerimenti

//you can see in your Android SDK folder divider is just an 9-patch image

android-sdk-windows\platforms\android-xx\data\res\values\styles.xml



<style name="Widget.ListView" parent="Widget.AbsListView">
        <item name="android:listSelector">@android:drawable/list_selector_background</item>
        <item name="android:cacheColorHint">?android:attr/colorBackgroundCacheHint</item>
        <item name="android:divider">@android:drawable/divider_horizontal_dark_opaque</item>
    </style>

    <style name="Widget.ListView.White" parent="Widget.AbsListView">
        <item name="android:listSelector">@android:drawable/list_selector_background</item>
        <item name="android:cacheColorHint">?android:attr/colorBackgroundCacheHint</item>
        <item name="android:divider">@android:drawable/divider_horizontal_bright_opaque</item>
    </style>

i bet that it depends on android version/style being used/phone manufacturer changes.

quick look at the android sources:

TypedArray a = context.obtainStyledAttributes(attrs,
            com.android.internal.R.styleable.ListView, defStyle, 0);

// Use the height specified, zero being the default
final int dividerHeight = a.getDimensionPixelSize(
            com.android.internal.R.styleable.ListView_dividerHeight, 0);
if (dividerHeight != 0) {
    setDividerHeight(dividerHeight);
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top