3

私は RecyclerView を使用しており、CardView も使用しています。これらすべての標準手順を作成しました (ViewHolder を作成し、必要なメソッドを実装しました) が、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()));

        }

    }

この問題を解決する方法を知っている人はいますか?

4

3 に答える 3

0

カードビューを使用している場合は、このコードを使用してください

<android.support.v7.widget.CardView
            android:id="@+id/cardview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:elevation="100dp"
            card_view:cardBackgroundColor="@color/cardview_initial_background"
            card_view:cardCornerRadius="8dp"
            android:layout_marginLeft="@dimen/margin_large"
            android:layout_marginRight="@dimen/margin_large"
            >
于 2016-11-14T18:18:19.307 に答える