1

Ich brauche einen Textview genau bestimmten Teil des Fotos stelle ich von unten xml verwenden, aber ich setzte alle Größe Handbuch muß ich für unterschiedliche Größe Mobil dynamisch sein:Android - Legen Sie einen TextView genau bestimmten Teil des Fotos?

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

Antwort

0

ich mein Problem beheben:

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

0

Have hast du es mit einem frameLayout versucht? setzen Sie die Schwerkraft zu right | top und es sollte

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 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/ic_launcher" /> 

    <TextView 
     android:id="@+id/CallCenter" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="test" 
     android:textSize="20sp" 
     android:textColor="@android:color/background_dark" 
     android:textStyle="bold" 
     android:layout_gravity="right|top" /> 

</FrameLayout> 
+0

Kann die Person, die meine Antwort nicht mochte mir sagen, warum zumindest? –

0

auf jedem Gerät funktionieren, wenn Sie RelativeLayout als root verwenden müssen, Sie layout_alignParentX Eigenschaften verwenden können.

<?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:layout_alignParentEnd="true" 
     android:layout_alignParentRight="true" 
     android:textColor="@android:color/background_dark" 
     android:textStyle="bold" /> 
</RelativeLayout> 

Aber wenn Sie nicht brauchen, empfehle ich eine FrameLayout als root zu verwenden, um eine Doppel Aufruf invalidate() von RelativeLayout zu vermeiden.

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 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/ic_launcher" /> 

    <TextView 
     android:id="@+id/CallCenter" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right|end" 
     android:text="test" 
     android:textSize="20sp" 
     android:textColor="@android:color/background_dark" 
     android:textStyle="bold" /> 
</FrameLayout>