如何使用卡片视图 android 在相对布局的中心添加垂直线?

How to add vertical line in center of Relative layout using card view android?

我想使用更细的垂直线将相对布局分成两部分。

这样我就可以使用卡片视图轻松使用相对布局的全宽。

我还想让我的卡片视图可以点击,当我点击特定的卡片视图时,它将进入另一个布局并显示关于点击数据的所有详细信息。

任何人都可以推荐或建议我进行卡片查看点击吗?

这是我的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">

<android.support.v7.widget.CardView
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:id="@+id/card_view"
    android:layout_marginBottom="3dp"
    app:cardBackgroundColor="@color/cardview_light_background">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:paddingBottom="10dp"
        android:id="@+id/rel_personal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Example Name"
            android:fontFamily="sans-serif-medium"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="15dp"
            android:layout_alignParentTop="true"
            android:id="@+id/person_name"
            android:textColor="#000000"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/person_name"
            android:text="example@gmail.com"
            android:fontFamily="sans-serif-light"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="5dp"
            android:id="@+id/person_email"
            android:textColor="#000000"/>

    </RelativeLayout>

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

要创建垂直分隔线,您可以在布局中的任意位置使用虚拟视图,例如:

<View android:layout_width="2dp" 
      android:layout_height="match_parent"
      android:background="#000"/>

另外,为了使您的 cardView 可点击,您可以像使用任何其他类型的视图一样使用其 setOnClickListener 方法。