I am displaying some items in a RecyclerView
. In the layout of each item, I want a vertical bar to appear. I created an ImageView
in the item layout. It is seen OK in the Design preview tab, but it is not seen in the device.
I have seen this question, similar to mine, but anything of that is working.
This is the layout (The testing device is a Samsung):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainrl">
<ImageView
android:layout_width="3dp"
android:layout_height="match_parent"
android:background="@color/backcolor"
android:layout_marginStart="50dp"
android:id="@+id/verticalbar"/>
<android.support.v7.widget.CardView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/daycv"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
card_view:cardCornerRadius="30dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardBackgroundColor="@color/backcolor">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/day"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textColor="@color/white"
android:textSize="17sp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/day"
android:background="@color/white"
android:id="@+id/separador"
android:layout_marginStart="3dp"
android:layout_marginEnd="3dp"
android:layout_centerVertical="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/month"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="@+id/separador"
android:textColor="@color/white"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:layout_toEndOf="@+id/daycv"
android:layout_alignTop="@+id/daycv"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:id="@+id/contentcv">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rl">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/image"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:alpha="150"
android:background="@color/gris">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/origen"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/flecha"
android:layout_toEndOf="@+id/origen"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"
android:background="@android:drawable/ic_media_ff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/destino"
android:layout_toEndOf="@+id/flecha"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:alpha="150"
android:background="@color/gris">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="@+id/voidimage"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fechasalida"
android:layout_above="@+id/voidimage"
android:layout_alignParentStart="true"
android:layout_marginStart="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fechallegada"
android:layout_alignStart="@+id/fechasalida"
android:layout_below="@+id/voidimage"
android:layout_marginBottom="10dp"/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
Why is my ImageView not been seen in device?
Thank you.
EDIT:
Image:
EDIT 2:
I have changed my layout to this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainrl">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/cvrl">
<!--<android.support.v7.widget.CardView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/daycv"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
card_view:cardCornerRadius="30dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardBackgroundColor="@color/backcolor">-->
<android.support.v7.widget.CardView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/daycv"
android:layout_centerHorizontal="true"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
card_view:cardCornerRadius="30dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardBackgroundColor="@color/backcolor">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/day"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textColor="@color/white"
android:textSize="17sp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/day"
android:background="@color/white"
android:id="@+id/separador"
android:layout_marginStart="3dp"
android:layout_marginEnd="3dp"
android:layout_centerVertical="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/month"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="@+id/separador"
android:textColor="@color/white"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<ImageView
android:layout_width="3dp"
android:layout_height="wrap_content" <---- Changing this affects how the vertical line sees.
android:src="@color/backcolor"
android:layout_marginStart="40dp"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:id="@+id/verticalbar"/>
</RelativeLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:layout_toEndOf="@+id/cvrl"
android:layout_alignTop="@+id/cvrl"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:id="@+id/contentcv">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rl">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/image"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:alpha="150"
android:background="@color/gris">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/origen"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/flecha"
android:layout_toEndOf="@+id/origen"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"
android:background="@android:drawable/ic_media_ff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/destino"
android:layout_toEndOf="@+id/flecha"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:alpha="150"
android:background="@color/gris">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="@+id/voidimage"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fechasalida"
android:layout_above="@+id/voidimage"
android:layout_alignParentStart="true"
android:layout_marginStart="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fechallegada"
android:layout_alignStart="@+id/fechasalida"
android:layout_below="@+id/voidimage"
android:layout_marginBottom="10dp"/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
If I put height: match_parent, only a bit of the line is seen. but, if I set to a random number (300dp, for example) the line is shown...