我與RecyclerView工作,我用的是CardView作爲well.I已做了所有這些標準程序(創建ViewHolder,履行了必要的方法),但問題是,CardView的角落麥凱納t rounded.I只得到CardView的矩形角落。CardView不能正常工作
這裏是適配器的 「主佈局」 的XML代碼:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_margin="15dp"
card_view:cardElevation="10dp"
card_view:cardCornerRadius="30dp">
<RelativeLayout
android:layout_margin="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/adapterText"
android:text="@string/textCaption"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/adapterDate"
android:text="@string/date"
android:layout_marginTop="10dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_below="@+id/adapterText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</android.support.v7.widget.CardView>
而且隨着RecyclerView另一個佈局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/contactList"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
和初始化RecyclerView的:
@Override
public void onViewCreated(View root, Bundle savedInstanceState) {
if (root != null) {
RecyclerView mRecyclerContactList=(RecyclerView)(root.findViewById(R.id.contactList));
mContactAdapter=new ContactAdapter(getContext(),mContextualMultiMode,mContactList);
mRecyclerContactList.setAdapter(mContactAdapter);
RecyclerView.ItemAnimator animator=new DefaultItemAnimator();
mRecycle
rContactList.setItemAnimator(animator);
RecyclerView.ItemDecoration mVerticalDecoration=new DividerItemDecoration
(getContext(), LinearLayoutManager.VERTICAL);
mRecyclerContactList.addItemDecoration(mVerticalDecoration);
mRecyclerContactList.setLayoutManager(new LinearLayoutManager(getContext()));
}
}
不任何人都知道如何解決這個問題?
哪個版本的Android,你在測試此? – amitairos
我用牛軋糖,7.0 – nullbyte
它是一個水平Recyclerview?你能發佈你的整個佈局xml嗎? – amitairos