1

I want to split Relative layout into two part using a thiner vertical line.

So that i easily use full width of Relative layout using Card View.

Also i want to make my card view clickable when i click on particular card view it will go another layout and show all details of regarding to clicked Data.

Can anyone refer or suggest me for card view click ?

here is my code:

<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>

Manish Tiwari
  • 1,806
  • 10
  • 42
  • 65

1 Answers1

1

For creating a vertical divider you can use a dummy view wherever you want in your layout like :

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

Also for making your cardView clickable , you can use its setOnClickListener method like any other kind of view.

Farhad
  • 12,178
  • 5
  • 32
  • 60
  • Add it inside the relativelayout and make it center_inParent=true. this way it splits the relativelayout in half – Farhad Feb 16 '16 at 18:27
  • 2
    I saw vertical line android studio preview but run in virtual device no vertical line shows. – Manish Tiwari Feb 16 '16 at 18:31
  • Probably other views are hovering it. check to see if any sibling view of that vertical view, is set to match_parent in width or height. Try playing with its siblings to find out the problem – Farhad Feb 16 '16 at 18:33
  • Thanks for the accepted answer, please upvote if you don't mind – Farhad Feb 16 '16 at 19:23