2016-11-10 9 views
17

için çizilebilir ayarlanıyorum DividerItemDecoration için özel çekilebilir (satır) ayarlamıyorum, ancak hiç bir başarıya sahip değilim. Hata nerede?DividerItemDecoration

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

XML şekli:

<?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> 
+2

, size 'android ayarlayabilirsiniz,' DividerItemDecoration # setDrawable' gerekmez. – arekolek

cevap

27

Değişim dikdörtgen için şekil.

Ör: yerine tema listDivider` niteliğini: Bu arada

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
    <size 
     android:width="1dp" 
     android:height="1dp" /> 
    <solid android:color="@color/primary" /> 
</shape>