Android的后台隐藏子视图的文本 [英] Android background hides child view text

查看:96
本文介绍了Android的后台隐藏子视图的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的LinearLayout。当我添加了机器人:背景到的LinearLayout,在的TextView 不再可见。

什么是我不理解?

 <的LinearLayout
   机器人:ID =@ + ID / LinearLayout01
   机器人:layout_width =FILL_PARENT
   机器人:layout_height =53px
   机器人:背景=@可绘制/ glossy_black_top_bar
   >

       < TextView的Andr​​oid版本:文本=这是标题
       机器人:ID =@ + ID / TextView01
       机器人:layout_width =WRAP_CONTENT
       机器人:layout_height =WRAP_CONTENT
       机器人:重力=center_vertical
       机器人:文字颜色=#FFFFFF>
       < / TextView的>
< / LinearLayout中>
 

解决方案

看来,LinearLayouts与背景展开wierdly。我只是用的FrameLayout来创建一个标题。下面是XML,如果有人想一,它需要一个ImageView的指向一个NinePatched背景和延伸了。

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
   机器人:方向=垂直
   机器人:layout_width =FILL_PARENT
   机器人:layout_height =FILL_PARENT>

<的FrameLayout
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT>

     < ImageView的机器人:ID =@ + ID / ImageView01
         机器人:layout_width =FILL_PARENT
         机器人:layout_height =WRAP_CONTENT
         机器人:SRC =@可绘制/ glossy_black_top_bar
         机器人:layout_alignParentTop =真
         机器人:scaleType =fitXY>
     < / ImageView的>

    <的LinearLayout
           机器人:ID =@ + ID / LinearLayout01
           机器人:layout_width =FILL_PARENT
           机器人:layout_height =WRAP_CONTENT
           机器人:方向=横向>

             < TextView的Andr​​oid版本:文本=我的标题TITLE
             风格=@风格/标题
               机器人:ID =@ + ID / TextView01
               机器人:layout_width =FILL_PARENT
               机器人:layout_height =WRAP_CONTENT
               机器人:重力=中心
               机器人:layout_gravity =中心
               机器人:则shadowColor =#000000
               机器人:shadowRadius =5
               机器人:shadowDx = -  5
               机器人:shadowDy = -  5
               机器人:paddingTop =5dip>
               < / TextView的>
    < / LinearLayout中>
< /的FrameLayout>

<的WebView机器人:ID =@ + ID / WebView01机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT>< /的WebView>

< / LinearLayout中>
 

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

What am I not understanding?

<LinearLayout 
   android:id="@+id/LinearLayout01" 
   android:layout_width="fill_parent" 
   android:layout_height="53px"
   android:background="@drawable/glossy_black_top_bar"
   >

       <TextView android:text="This is the Title" 
       android:id="@+id/TextView01" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"
       android:gravity="center_vertical"
       android:textColor="#FFFFFF">
       </TextView>
</LinearLayout>

解决方案

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>

这篇关于Android的后台隐藏子视图的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆