Ensemble drawable pour DividerItemDecoration

Je suis en train de configurer mon personnalisée drawable (ligne) pour DividerItemDecoration, mais sans succès. Où est l'erreur?

DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(),
                LinearLayoutManager.VERTICAL);
dividerItemDecoration.setDrawable(getContext().getResources().getDrawable(R.drawable.sk_line_divider));

XML de la forme:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    <stroke
        android:width="1dp"
        android:color="#000000">
    </stroke>
</shape>
  • En passant, vous n'avez pas besoin DividerItemDecoration#setDrawable, vous pouvez définir android:listDivider attribut dans votre thème à la place.
InformationsquelleAutor user3352926 | 2016-11-10