2011-03-18 79 views
0

有沒有辦法設置scrollview元素的背景顏色?我試過下面的下面的代碼,但都沒有被應用顏色:Android滾動查看背景顏色

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/ScrollView01" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:scrollbars="vertical" android:background="@color/colorWhite"> 
<?xml version="1.0" encoding="utf-8"?> 

<resources> 
    <string name="app_name">Trackfolio</string> 
    <color name="colorWhite">#FFFFFF</color> 
    <color name="colorBlack">#000000</color> 
    <color name="colorLightBlue">#33A1C9</color> 
</resources> 
+0

這就是全部在一個文件?佈局和資源類型應該位於不同的文件中。所以你需要res/layout/scrollview.xml,res/values/resources.xml。但如果它們在單獨的文件中,那麼你的語法看起來是正確的ScrollView內的內容是否正確顯示? – 2011-03-18 21:50:59

+1

是的,他們在不同的文件。這些是代碼剪輯 – locoboy 2011-03-18 21:59:48

+0

你在Scrollview中嵌套了什麼樣的元素? – Jorgesys 2011-03-18 22:50:55

回答

4

試試這個`

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <ScrollView 
     android:layout_width="100dip" 
     android:layout_height="120dip" 
     android:background="#FF0000"> 
     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 


      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/scrollbar_2_text" /> 
     </LinearLayout> 
    </ScrollView> 

    <ScrollView 
     android:layout_width="100dip" 
     android:layout_height="120dip" 
     android:background="#00FF00" 
     android:paddingRight="12dip"> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/scrollbar_3_text" 
      android:textColor="#000000" 
      android:background="#60AA60" /> 
    </ScrollView> 

    <ScrollView 
     android:id="@+id/view3" 
     android:layout_width="100dip" 
     android:layout_height="120dip" 
     android:background="@android:drawable/edit_text"> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:textColor="#000000" 
      android:text="@string/scrollbar_3_text" /> 
    </ScrollView> 
</LinearLayout> 

`

0

我不知道這是否是這樣做的正確方法,但我裹滾動在另外的LinearLayout和設置背景白色和它的工作。