Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android textview on imageview

I am trying to place an TextView on a ImageView in the bottom center of the RelativeLayout. I am able to place the TextViewin the center but not able to place it in the bottom . Can anyone guide me. here is my XML

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

    <ImageView
        android:id="@+id/eventimage"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:background="#000000">
   </ImageView>

    <TextView
            android:id="@+id/text98"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_centerVertical="true"            
            android:singleLine="true"
            android:textColor="@color/white"        
            android:text="LAST"
            android:textStyle="bold"
            android:textSize="18sp"/>
</RelativeLayout> 
like image 613
Vidya Avatar asked Dec 29 '25 03:12

Vidya


2 Answers

on the textView use the following attributes android:layout_centerHorizontal="true" instead of android:layout_centerVertical="true" and add android:alignParentBottom=true". Also look at the relative layout options to understand how to work with it.

like image 147
bogdan Avatar answered Dec 30 '25 15:12

bogdan


try

<TextView
        android:layout_alignParentBottom="true"
...
like image 39
Anton Bevza Avatar answered Dec 30 '25 15:12

Anton Bevza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!