Кардвал с разделителями в нем

Я видел те CardViews (я не уверен, что они даже CardViews) с разделителями, используемыми во многих приложениях, поэтому я предполагаю, что есть простой способ их создания. Я хотел спросить, как это делается? те, что даже CardViews?

Я не мог узнать больше о них, потому что я точно не знал имя View, поэтому, если бы кто-то мог направить меня к примеру с кодом, я был бы благодарен.

Пример изображения: enter image description here

Ответы

Ответ 1

Вы можете использовать этот код, это может помочь

 <android.support.v7.widget.CardView
        android:id="@+id/cardview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/margin_large"
        android:layout_marginRight="@dimen/margin_large"
        android:elevation="100dp"
        card_view:cardBackgroundColor="@android:color/white"
        card_view:cardCornerRadius="8dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:gravity="center_vertical"
                android:paddingLeft="25dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Conversations" />
            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:background="@android:color/darker_gray" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingLeft="30dp"
                android:paddingTop="20dp"
                android:paddingBottom="10dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="game" />
                    ...
            </LinearLayout>
        </LinearLayout>
    </android.support.v7.widget.CardView>

Ответ 2

Показанный снимок экрана показывает нормальный CardView с представлениями как разделитель между ними. Нет DividerView или что-то подобное, если вы ищете что-то вроде этого. Просто используйте простой View с высотой и фоном.

У меня что-то похожее в моей библиотеке. Я использую это для создания разделителя:

<View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/stroke"/>

card_library.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"
              android:paddingBottom="8dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/libraryname"
            style="@style/CardTitle"
            android:fontFamily="sans-serif-condensed"
            android:textStyle="normal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxLines="1"/>

        <TextView
            android:id="@+id/libraryversion"
            style="@style/CardTitle"
            android:fontFamily="sans-serif-condensed"
            android:textStyle="normal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="4dp"
            android:layout_marginTop="4dp"
            android:gravity="left|bottom"
            android:maxLines="1"
            android:textSize="12sp"/>

        <TextView
            android:id="@+id/librarycreator"
            style="@style/CardTitle"
            android:fontFamily="sans-serif-condensed"
            android:textStyle="normal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="2dp"
            android:gravity="right"
            android:maxLines="2"
            android:textSize="14sp"/>
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="4dp"
        android:background="@color/stroke"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:padding="4dp">

        <TextView
            android:id="@+id/description"
            style="@style/CardText"
            android:fontFamily="sans-serif-condensed"
            android:textStyle="normal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:maxLines="20">
        </TextView>
    </LinearLayout>

</LinearLayout>

Он будет выглядеть следующим образом:

Divider

Ответ 3

Установите приложение: cardElevation = "0dp", затем используйте View - см. ниже

<android.support.v7.widget.CardView
android:id="@+id/cv"
xmlns:android="http://schemas.android.com/apk/res/android"
app:cardElevation="0dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">

<!-- Insert UI elements -->

    <View
        android:layout_width="fill_parent"
        android:background="@android:color/darker_gray"
        android:layout_height="2dp"/>

</android.support.v7.widget.CardView>