我在滚动布局中添加了一个线性布局,结果线性布局的背景色设置了不起作用了。哪位大侠知道呀,先谢谢了~~
<ScrollView android:id="@+id/ScrollView01" 
android:layout_height="fill_parent" 
android:layout_width="fill_parent">
<LinearLayout android:id="@+id/LinearLayout01" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
请给位高手给看看

解决方案 »

  1.   


    <ScrollView android:id="@+id/ScrollView01" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent">
    <LinearLayout android:id="@+id/LinearLayout01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:background="@drawable/green">
    </LinearLayout>
    </ScrollView>
      

  2.   

    你的颜色有没有定义啊? res/values/color.xml
    <drawable name=green>0xff00ff00</color>
      

  3.   

      不知道 ~ 在  ScrollView  找找属性 看能设置不 
      

  4.   

    个人觉得问题可能出在线性布局的layout_width与layout_height上,你把它们也都改成fill_parent试试看。wrap_content是自动适应,你的线性布局里什么widget都没放,当然它的背景色你看不到。
      

  5.   

    我上面代码就是个例子;实际上我都用的是充满:fill_parent  哎~~~~怎么弄都不行
    单一的线性布局怎么弄都可以,把它放在滚动布局中就不行了。
      

  6.   

    定义的颜色还得在代码里面取出来Resources  res = getBaseContext().getResources();
            Drawable d = res.getDrawable(R.drawable.other<color.xml文件中的名称>); 
      

  7.   

    Try setting layout_width and layout_height to an actual pixel amount instead of fill_parent or wrap_content. This solved the problem for me. 
    http://androidforums.com/application-development/50090-custom-view-inside-scrollview.html
    可以把ScrollView的宽高设置为固定值试试。
      

  8.   

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent">
        <LinearLayout 
        android:id="@+id/LinearLayout01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" android:background="@drawable/lbl">
        <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
        </LinearLayout>
    </ScrollView>
    如5楼  说的 ,你必须在里面加了组件阿 才能看出背景颜色啊  你什么都没有 怎么能看到呢我试过了 可以看到的
      

  9.   

    “你必须在里面加了组件阿 才能看出背景颜色啊”
    我也试了,可以看到的,你不妨在linearLayout里面放一个 Button,试试
      

  10.   

    单一的LinearLayout,我不添加TextView这个组件,即使我什么都不加他都可以设置背景色的,可以把它包到ScrollView中就不行了。还有吧LinearLayout包到ScrollView中,他根本就填充不满。他的高度总是取决于组件,比如我里面放一个TextView,TextView多高,LinearLayout就多高TextView设置fill_parent 也是不行 如果是独立的LinearLayout 我设置它的高度是fill_parent 的话他是可以填满的。为什么呀着急死了
      

  11.   

    那是不可能的 单一的LinearLayout我也试过 不加组件是出不来的
    你高错了!
      

  12.   

    ScrollView的处理比较特殊,尤其ScrollView中包含一个ListView的时候,高度就不是按照预想的了。
    需要特殊处理。
    继续关注
      

  13.   


      我就是加了一个ListView  怎么处理   求解 !
      

  14.   

    but我在这边试了 它没有颜色阿
      

  15.   

    各位朋友,实在解决不了。那怎么让一个线性布局(LinearLayout)加个滚动条,不利用ScrollView。一个线性布局LinearLayout,竖向的。里面加很多TextView,如果太多的话让他出现滚动条
      

  16.   

    用ListView不行吗?自定义item由TextView组成。
      

  17.   

    我发现问题的现象是:模拟器上可以出来,但真机总是黑色,,why?