I have a ImageView on a Map frangment which both of them placed in a ConstraintLayout. I set android:translationZ="2dp" and then android:elevation="2dp" for ImageView but still can't see image.
map_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/mapView"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context=".MapsActivity" />
<ImageView
android:id="@+id/testImage"
android:layout_width="64dp"
android:layout_height="64dp"
app:layout_constraintBottom_toBottomOf="@+id/mapView"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/test"
android:translationZ="2dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
The weird thing is, I set an OnClickListener to image and I can click it. It looks like ImageView is there, on the top of map fragment but I can't see it.
How can I send map fragment to back or bring views to front?
Changing app:srcCompat
with android:src
worked fine. Final xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/mapView"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context=".MapsActivity" />
<ImageView
android:id="@+id/testImage"
android:layout_width="64dp"
android:layout_height="64dp"
app:layout_constraintBottom_toBottomOf="@+id/mapView"
app:layout_constraintStart_toStartOf="parent"
android:src="@drawable/test"
android:translationZ="2dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Thanks to @mohosyny and @ReazMurshed.