我有一个 RecyclerView 的工作,我也使用 CardView。我已经制定了所有这些标准程序(创建了 ViewHolder,实现了必要的方法),但问题是 CardView 的角不是圆角的。我只得到矩形角卡片视图。
下面是 Adapter 的“主布局”的 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()));
}
}
有谁知道如何解决这个问题?