2011-06-07 1 views
0

2つのTextViewをオーバーラップさせて、個々の文字が完全に重なるようにします(つまり、画面に別のTextViewが表示されないこともあります)。レンダリングされたときTextViewsで重複するテキストを整列する

<com.testing.android.animals.OutlinedTextView 
android:id="@+id/label_left_name" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:text="Elephant" 
android:layout_alignTop="@id/picture_left" 
android:layout_centerHorizontal="true" 
android:textColor="#ffffff" 
android:textSize="40dp" 
android:background="#99000000" 
></com.testing.android.animals.OutlinedTextView> 

<com.testing.android.animals.OutlinedTextView 
android:id="@+id/label_left_letter" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:text="E" 
android:layout_alignBaseline="@id/label_left_name" 
android:layout_alignLeft="@id/label_left_name" 
android:textColor="#ffffff" 
android:textSize="40dp" 
android:background="#99ffffff" 
></com.testing.android.animals.OutlinedTextView> 

が、それは次のようになります:

enter image description here

お知らせ個々の「E」(ライトグレー)が高すぎると整列される。ここに私のレイアウトの関連する部分があります。

レイアウトを変更して、よりよくオーバーラップさせることはできますか?

答えて

0

pは、フルワードのテキストビューの下端をより大きくすることが問題です。高さとしてwrap_contentがあるので、textviewsの2つの高さが異なります。

各テキストビューの高さを特定のサイズ(同じサイズ)に設定した場合、それらは一直線に並ぶ必要があります。

しかし、私はあなたのアプローチが間違っていると思うかもしれません - フォーマットのためにスパン可能な文字列を調べるか、とにかくカスタムコントロールを使用しているように見えるので、最初の文字のフォーマットをします。 (ここにスパニング可能な文字列の例:http://www.chrisumbel.com/article/android_textview_rich_text_spannablestring

+0

"Elephant"という単語全体を含むSpnnable文字列を使用しましたが、 "lephant"部分は透明でした。 – Matt

関連する問題