Android background hides child view text

前端 未结 1 1653
有刺的猬
有刺的猬 2021-01-16 11:56

I have a simple LinearLayout. When I add the android:background to the LinearLayout, the TextView is no longer visible.

What am I

相关标签:
1条回答
  • 2021-01-16 12:22

    It seems that LinearLayouts with backgrounds expand wierdly. I just used a Framelayout to create a header. Here's the XML if anyone wants I. It takes an ImageView that points to a NinePatched background and stretches it.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">
    
    <FrameLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    
         <ImageView android:id="@+id/ImageView01" 
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content"
             android:src="@drawable/glossy_black_top_bar"
             android:layout_alignParentTop="true"
             android:scaleType="fitXY">
         </ImageView>
    
        <LinearLayout 
               android:id="@+id/LinearLayout01" 
               android:layout_width="fill_parent" 
               android:layout_height="wrap_content" 
               android:orientation="horizontal">
    
                 <TextView android:text="MY HEADER TITLE" 
                 style="@style/title"
                   android:id="@+id/TextView01" 
                   android:layout_width="fill_parent" 
                   android:layout_height="wrap_content"
                   android:gravity="center"
                   android:layout_gravity="center"
                   android:shadowColor="#000000"
                   android:shadowRadius=".5"
                   android:shadowDx="-.5"
                   android:shadowDy="-.5"
                   android:paddingTop="5dip">
                   </TextView>
        </LinearLayout>
    </FrameLayout>
    
    <WebView android:id="@+id/WebView01" android:layout_width="fill_parent" android:layout_height="fill_parent"></WebView> 
    
    </LinearLayout>
    
    0 讨论(0)
提交回复
热议问题