Reputation: 5
I'm trying to send the white image in the back of my button and text in Relative Layout. Here is the code:
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.sahni.lightspeed.starting_screen"
tools:showIn="@layout/activity_starting_screen"
android:background="@drawable/q1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"
android:textSize="70sp"
android:id="@+id/title"
android:textColor="#00e1ff"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/start_button"
android:id="@+id/button"
android:textSize="20sp"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:onClick="buttonOnClick"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView"
android:layout_alignLeft="@+id/title"
android:layout_alignStart="@+id/title"
android:layout_below="@+id/title"
android:background="#ffffff" />
</RelativeLayout>
The layout sets for the image aren't correct, but I don't know which ones to use to get the output I want. A screenshot of current output:
Upvotes: 0
Views: 3092
Reputation: 7653
Just move to first ImageView
in your RelativeLayout
:
<RelativeLayout ... >
<ImageView ... />
<TextView ... />
<Button ... />
</RelativeLayout>
Your ImageView
has android:layout_below="@+id/title"
property so it' always below your title, so it can't be in background of your title.
Upvotes: 1