我有這個簡單的佈局回收視圖項目。DividerItemDecoration沒有顯示android
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/details"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="?android:attr/selectableItemBackground"
android:paddingEnd="15dp"
android:paddingStart="15dp"
>
<org.tchouaffe.ftinfosystem.utils.CustomTextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textColor="@color/primaryTextColor"
android:textSize="15sp"/>
<org.tchouaffe.ftinfosystem.utils.CustomTextView
android:id="@+id/level"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/name"
android:gravity="center_vertical|right"
android:textColor="@color/primaryTextColor"
android:textSize="15sp"/>
</RelativeLayout>
而下面的代碼執行設置回收站視圖:
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
MyAdapter adapter = new MyAdapter(activity, elementList);
adapter.setHasStableIds(true);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView
.getContext(), DividerItemDecoration.VERTICAL);
recyclerView.addItemDecoration(dividerItemDecoration);
recyclerView.setHasFixedSize(false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
未知原因分頻器沒有顯示出來。 任何想法?我正在使用。
感謝
對於垂直檢查這個http://stackoverflow.com/a/27037230/2870088 –
你想使用什麼'Drawable'? – pskink
嗨@pskink。 Drawable是什麼意思? – DeKekem