テキストボックス(複数行、ほぼ5行)と画像ビューを持つ線形レイアウトがあります。テキストビュー(オーバーラップ)に画像を描画することはできますか?
注: 画像の座標を指定する必要があります。これは静的ではなく、テキストの上のどこにでもある可能性があります。
このモックアップのようなもの:
テキストボックス(複数行、ほぼ5行)と画像ビューを持つ線形レイアウトがあります。テキストビュー(オーバーラップ)に画像を描画することはできますか?
注: 画像の座標を指定する必要があります。これは静的ではなく、テキストの上のどこにでもある可能性があります。
このモックアップのようなもの:
RelativeLayout を使用して実現できると思います。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/Textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="@string/Text2display"
android:textColor="#EEDCAA" />
<ImageView
android:id="@+id/choose_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="-46dp"
android:adjustViewBounds="true"
android:contentDescription="@string/description_logo"
android:src="@drawable/user2" />
</RelativeLayout>
TextView ブロックを ImageView の上に配置することで、画像ビューが TextView にオーバーラップするようになります。ここで、要件と位置に基づいて、リンクから次のコマンドを使用します。
http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html
上下左右揃えることができます。負の値を使用して ImageView をナビゲートします。下の位置合わせなどを使用している場合は、オーバーラップします。これが役に立ったかどうか教えてください
Linear Layout の特定の理由はありますか?
本当に (本当に) LinearLayout を使用する必要がある場合は、TextView をサブクラス化し、onDrawをオーバーライドして画像を描画できます。
RelativeLayout を使用すると、これを簡単に行うことができます。LinearLayout を使用する特定の理由がない限り、 ImageView を TextView と重ねることができます。