-1

I want to create a divider, which would look exactly like a divider in ListView and will depend on a current theme.

<View android:id="@+id/first_line"
          android:layout_width="match_parent"
          android:layout_below="@+id/description"
          android:layout_height="1dp"
          android:layout_marginBottom="7dp"
          android:layout_marginTop="7dp"
          android:background="?attr/colorPrimaryDark"/>

Which attribute should I specify in this line android:background="attr/colorPrimaryDark" to handle this?

Semyon Tikhonenko
  • 3,872
  • 6
  • 36
  • 61

1 Answers1

1

Check android styles file. Divider in ListView it's a drawable. For example:

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

So you can create a View:

<View
    android:id="@+id/my_divider"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:drawable/divider_horizontal_dark"/>

See the drawable from same theme that your app(for example).

Tronum
  • 707
  • 3
  • 13