Component on another Android

Asked

Viewed 329 times

2

I am developing an application using android studio 2.2.2 and would like my application to look like this:

inserir a descrição da imagem aqui

But when putting textView on the imageView it is under the image, I tried to use frameLayout and linearLayout but could not

inserir a descrição da imagem aqui

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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="wrap_content"
android:layout_height="wrap_content" >

<RelativeLayout 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"
tools:context="com.example.tulio.exe1.MainActivity">

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:background="@android:color/background_light"
    android:text="Feliz Aniversario Maria"
    android:textColor="#FFFFFF" />

  <TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="ASS: Felipe"
    android:textColor="#fffffff"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentBottom="true"
     />

<ImageView
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"
    app:srcCompat="@drawable/aniver"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />



  </RelativeLayout>
  </FrameLayout>

1 answer

1


The RelativeLayout takes into account the order of the elements, so put first the ImageView first to get him behind the TextView

Follows:

 <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:context="com.example.tulio.exe1.MainActivity">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/imageView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                app:srcCompat="@drawable/aniver"
                android:scaleType="fitXY" />


            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:background="@android:color/background_light"
                android:text="Feliz Aniversario Maria"
                android:textColor="#FFFFFF" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:text="ASS: Felipe"
                android:textColor="#fffffff" />

        </RelativeLayout>
    </FrameLayout>
  • 1

    that’s right thanks for the help

Browser other questions tagged

You are not signed in. Login or sign up in order to post.