我想使用更细的垂直线将相对布局分成两部分。
这样我就可以使用Card View轻松使用相对布局的全宽度。
此外,当我点击特定卡片视图时,我想让我的卡片视图可点击它将进入另一个布局并显示有关所点击数据的所有细节。
任何人都可以参考或建议我进行卡片查看点击吗?
这是我的代码:
<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>
答案 0 :(得分:1)
要创建垂直分隔线,您可以在布局中的任何位置使用虚拟视图,如:
<View android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#000"/>
另外,为了使您的cardView可以点击,您可以像任何其他类型的视图一样使用 setOnClickListener 方法。