简体   繁体   English

如何在 Android 中有多层阴影/渐变

[英]How to have multi-layered kind of shadow/gradient in Android

I am trying to achieve this layout.我正在努力实现这种布局。 The upper part is a bit dark and it decreases as we move down making it complete transparent.上半部分有点暗,当我们向下移动时它会减少,使其完全透明。 I tried a couple of gradient variations but didn't get the desired results.我尝试了几种渐变变化,但没有得到想要的结果。 Does anybody have idea of how to achieve this.有没有人知道如何实现这一目标。 Is it gradient or shadow?是渐变还是阴影?

Create a gradient file and use this code you can increase or decrease transparency as you want创建一个渐变文件并使用此代码,您可以根据需要增加或减少透明度

layout-->new file-->layout resource file--> give any name布局-->新建文件-->布局资源文件-->任意命名

 <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
            <gradient android:startColor="#B71A1A1A"
                android:angle="270"
                android:centerColor="#00FFFFFF"
                android:endColor="#00FFFFFF"/>
        </shape>
    </item>
    </selector>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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