2012-01-05 19 views
0

TextLayoutとBackgroundcolorを持つViewという2つの要素を持つFrameLayoutを取得しました。 これは予期したとおりに表示されますが、ビューはTextviewをオーバーレイします。 どのように私は別の色のビューにこのレイアウトを膨張させているだけで消え去る。助言がありますか?2つの要素を持つFramelayout

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 
    <View 
     android:layout_width="wrap_content" 
     android:layout_height="10dp" android:background="#000" android:layout_gravity="bottom" android:id="@+id/viewActive"/> 
    <TextView 
     android:id="@+id/textViewName" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Medium Text" 
     android:textAppearance="?android:attr/textAppearanceMedium"/> 
</FrameLayout> 

これはするためのコードでは、あなたの平面図の幅は "wrap_content" に設定されている

LayoutInflater inflater = LayoutInflater.from(context); 
ViewGroup view2 = (ViewGroup) inflater.inflate(R.layout.frame_layout, null); 
anotherViewGroup.addView(view2); 
+0

TextViewはビューをオーバーレイする必要がありますか? TextViewの背景色を透明に設定しようとしましたか? – elijah

+0

**これは予期したとおりに表示されていますか?**はグラフィカルレイアウトを意味しますか? –

答えて

0

含まれています。つまり、ビューは自分のコンテンツと同じ大きさでなければならないが、コンテンツはないので、幅は実質的に0になり、見えなくなります。

「10dp」や「match_parent」のようにハードコードされた値に幅を設定してみてください。それはトリックを行う必要があります。

関連する問題