简体   繁体   中英

How to make dynamic background gradient in scrollView android

I want layout with dynamic background gradient. Start scroll from one color and at the end of scroll another color. If this screen without scroll, background looks like usual gradient.

Is there are any way to do it?

Thank a lot.

I'm not sure if this is what you mean.You can create a xml file in drawable and name it like background.xml . In this file, for example:

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:state_pressed="false">
        <shape android:shape = "rectangle>
        <gradient
           android:startColor="#`enter code here`"
           android:endColor="#`enter code here`"
           android:angle="..." />
        </shape>
      </item>
    </selector>

Then in the layout of your activity, you set background by @drawable/background.xml

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