2

Now I am getting the output like this(Text is at bottom of the screen),

enter image description here

But I want output like the following image.

enter image description here

This is my XML code:

 <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/rlBottom"
            >

            <ImageView
                android:id="@+id/coringImage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:src="@drawable/img_electricity"
                />

            <TextView
                android:id="@+id/fdc_tvUnGeneration"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/default_margin"
                android:layout_marginRight="@dimen/default_margin"
                android:textColor="@color/color_white"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:layout_below="@+id/fdc_tvAVGeneration"
                 android:layout_alignParentBottom="true"
                />
        </RelativeLayout>
Johnett Mathew
  • 307
  • 1
  • 10
  • 20
Keyur Nimavat
  • 3,595
  • 3
  • 13
  • 19

5 Answers5

1

Try this code...

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/rlBottom">

    <ImageView
       android:id="@+id/coringImage"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:src="@drawable/img_electricity"/>

    <TextView
       android:id="@+id/fdc_tvUnGeneration"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginLeft="@dimen/default_margin"
       android:layout_marginRight="@dimen/default_margin"
       android:layout_marginBottom="5dp"
       android:textColor="@color/color_white"
       android:textAppearance="?android:attr/textAppearanceSmall"
       android:layout_below="@+id/fdc_tvAVGeneration"
       android:layout_gravity="bottom|center"/>
</FrameLayout>
Abhishek Singh
  • 9,008
  • 5
  • 28
  • 53
0

You can use android:scaleType="fitXY" in your imageview

Jinal Patel
  • 699
  • 5
  • 15
0

Try This

<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="wrap_content"
tools:context="com.us.upen.mymusicplayer.ui.SplashActivity">

<ImageView
    android:id="@+id/coringImage"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/img_electricity" />

<TextView
    android:id="@+id/fdc_tvUnGeneration"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/coringImage"
    android:layout_alignParentStart="true"
    android:gravity="center"
    android:textAppearance="?android:attr/textAppearanceSmall" />
 </RelativeLayout>

I checked this

Upendra Shah
  • 2,218
  • 17
  • 27
0

1. Remove attribute android:layout_below and android:layout_alignParentBottom="true" from TextView

2. Add attribute android:layout_alignBottom="@+id/coringImage" and android:layout_marginBottom="10dp" to TextView.

FYI, here I used bottom margin as 10dp, you can change it as per your needs.

Here is an example:

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

    <ImageView
        android:id="@+id/coringImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher" />

    <TextView
        android:id="@+id/fdc_tvUnGeneration"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/default_margin"
        android:layout_marginRight="@dimen/default_margin"
        android:layout_marginBottom="10dp"
        android:textColor="@color/color_white"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:layout_alignBottom="@+id/coringImage"
        android:layout_centerHorizontal="true"
        android:text="I am a Text"/>
</RelativeLayout>

OUTPUT:

enter image description here

Hope this will help~

Ferdous Ahamed
  • 21,438
  • 5
  • 52
  • 61
0

you have to remove android:layout_alignParentBottom="true" from textview

       <RelativeLayout        xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
    android:id="@+id/coringImage"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/wood01_c_pia" />

<TextView
    android:id="@+id/fdc_tvUnGeneration"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/coringImage"
    android:gravity="center"
    android:text="test"
    android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>