如何在scrollView android中制作动态背景渐变(How to make dynamic background gradient in scrollView android)

编程入门 行业动态 更新时间:2024-10-25 04:26:46
如何在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

更多推荐

本文发布于:2023-07-30 00:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1320828.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:背景   动态   如何在   scrollView   gradient

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!