How to bring imageView in front of cardview ? When both are of Relative Layout childs
CardView has default elevation which is greater than ImageView, So we have to add greater elevation in ImageView than CardView's elevation.
e.g. imageView.setElevation(10);
and cardView.setElevation(5);
Now, its working fine on all devices.
Do it like this,
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myCardView"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardBackgroundColor="@android:color/transparent"
card_view:cardElevation="0dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_edit"
android:background="@android:color/transparent"/>
</android.support.v7.widget.CardView>
It will bring the ImageView
to front.
Write this line in your java code after initializing the ImageView
.
imageView.bringToFront();