Search code examples
androidandroid-imageviewtextviewandroid-relativelayout

android - Set a TextView exactly specific part of the photo?


I need to set a TextView exactly specific part of the photo I am using from bellow xml but i set all of size manual I need to be dynamic for different size mobile:

<?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">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:src="@drawable/list_back" />

    <TextView
        android:id="@+id/CallCenter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/background_dark"
        android:textStyle="bold" />
</RelativeLayout>

enter image description here


Solution

  • I resolve my problem :

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:src="@drawable/list_back" />
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
    
        <View
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"/>
    
        <TextView
            android:id="@+id/CallCenter"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:paddingLeft="5dp"
            android:paddingRight="15dp"
            android:layout_weight="3"
            android:textColor="@android:color/background_dark"
            android:textStyle="bold" />
    </LinearLayout>