简体   繁体   中英

Android Scroll View Background Color

Is there a way to set the background color for the scrollview element? I've tried the following code below but the colors aren't being applied:

<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>

Try this `

<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>

`

我不确定这是否是正确的方法,但是我将Scroll包装在另一个LinearLayout中,并将背景设置为白色,并且可以正常工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM