Image above RelativeLayout

2

I want to place the image (the star) above the RelativeLayout and centered horizontally.

Example of how it should look:

Example of how I have it right now:

Code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/head_bg"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:background="@drawable/head_bg">

        <ImageView
            android:id="@+id/btnClose"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="10dp"
            android:alpha="0.5"
            android:src="@drawable/cancel" />

    </RelativeLayout>

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/head_bg"
        android:background="#FFFFFF"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="10dp"
            android:gravity="center"
            android:text="Message..." />

    </LinearLayout>

    <ImageView
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:adjustViewBounds="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="-45dp"
        android:src="@drawable/favorite" />

</RelativeLayout>

I've tried with android:adjustViewBounds="true" in ImageView but, it does not work.

Any ideas?

    
asked by Robert Gomez 24.09.2018 в 21:55
source

0 answers