2

I have one design pattern, but i'm not sure how could i create this. This is how it should looks:

enter image description here

I'm still struggling with putting image view in front of cardview. Any thoughts about that or example how this could be done? Thanks!

This is what i have done:

<RelativeLayout android:id="@+id/containor"
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin">

<de.hdodenhof.circleimageview.CircleImageView
    android:id="@+id/iv_profile"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_centerHorizontal="true"
    android:layout_marginEnd="5dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginStart="5dp"
    android:src="@drawable/soccer_player"
    app:civ_border_color="@color/colorAccent"
    app:civ_border_width="2dp"/>

<android.support.v7.widget.CardView
    android:id="@+id/card"
    android:layout_width="400dp"
    android:layout_height="150dp"
    android:layout_marginTop="10dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/bg_card_review">

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Nije lose"
            android:textColor="@android:color/white"
            android:textSize="16sp"
            android:typeface="sans"/>

    </RelativeLayout>

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

Dusan Dimitrijevic
  • 3,169
  • 6
  • 22
  • 46
  • 2
    in frame layout and relative layout, layouts added last are on top. so just change the order in which you are writing them. and provide your parent layout too in question if shifting the order doesn't work – Mohammed Atif Oct 30 '16 at 17:31
  • 1
    Maybe this link could help you: http://stackoverflow.com/questions/34523871/how-to-bring-imageview-in-front-of-cardview-when-both-are-of-relative-layout-c – Joe Hackerberg Oct 30 '16 at 17:33

1 Answers1

5

You need to give a higher elevation for your ImageView. Try the following for example...

ViewCompat.setElevation(findViewById(R.id.iv_profile),yourCardView.getElevation() * 2);
Muhannad Fakhouri
  • 1,468
  • 11
  • 14