Android 如何使用卡片视图在相对布局的中心添加垂直线?
我想用一条更细的垂直线将相对布局分成两部分 因此,我很容易使用全宽度的相对布局使用卡的看法 此外,我想使我的卡视图可点击,当我点击特定的卡视图时,它将进入另一个布局,并显示有关点击数据的所有详细信息 有人能推荐我查看卡片吗 这是我的密码:Android 如何使用卡片视图在相对布局的中心添加垂直线?,android,android-cardview,android-relativelayout,Android,Android Cardview,Android Relativelayout,我想用一条更细的垂直线将相对布局分成两部分 因此,我很容易使用全宽度的相对布局使用卡的看法 此外,我想使我的卡视图可点击,当我点击特定的卡视图时,它将进入另一个布局,并显示有关点击数据的所有详细信息 有人能推荐我查看卡片吗 这是我的密码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_hei
<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可点击,您可以像使用任何其他类型的视图一样使用其设置ClickListener方法。请参阅lnk将提供的帮助,将其添加到relativelayout中并使其居中\u inParent=true。通过这种方式,它在Half中拆分了relativelayout。我看到了垂直线android studio预览,但在虚拟设备中运行,没有垂直线显示。可能其他视图正在悬停它。检查该垂直视图的任何同级视图是否设置为在宽度或高度上与父视图匹配。试着和它的兄弟姐妹一起玩来找出问题。谢谢你接受的答案,如果你不介意的话,请投票