1

私は、異なるサイズの携帯用動的にする必要がある、私は怒鳴るXMLから私が使用している写真のTextViewに正確に特定の部分を設定する必要がありますが、私はサイズマニュアルのすべてを設定します。アンドロイド - 写真のTextViewを正確に特定の部分に設定しますか?

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

答えて

0

私は私の問題を解決:

<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

持っていますあなたはフレームを試しましたレイアウト? right | topに重力を設定し、それはあなたがルートとしてRelativeLayoutを使用する必要がある場合、あなたはlayout_alignParentXプロパティを使用することができます

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

は私の答えを嫌って人はなぜ少なくとも私に言うことはできますか? –

0

すべてのデバイス上で動作するはずです。

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

しかし、あなたは必要としない場合、私はRelativeLayoutからinvalidate()にダブルの呼び出しを避けるためにルートとしてFrameLayoutを使用することをお勧めします。

<?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> 
関連する問題