如何在scrollView android中制作动态背景渐变(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.
最满意答案
我不确定这是不是你的意思。你可以创建一个drawable的XML文件,并将其命名为background.xml 。 在这个文件中,例如:
<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>然后在您的活动布局中,您通过@drawable/background.xml设置@drawable/background.xml
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
更多推荐
发布评论