小编Evg*_*niy的帖子

Android XML drawable 透明渐变不透明

我想创建一个像 Play Music 一样的透明渐变。

可绘制/shadow_up.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:angle="90"
        android:startColor="#FF00FF00"
        android:endColor="#00FFFFFF"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

布局/main_layout.xml:

 <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical">

                   <View
                        android:layout_width="match_parent"
                        android:layout_height="25dp"
                        android:background="@drawable/shadow_up"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

但是渐变不是透明的。如何解决这个问题?

在此处输入图片说明

Play Music 的渐变:

在此处输入图片说明

它透明。

android android-drawable

4
推荐指数
1
解决办法
1652
查看次数

标签 统计

android ×1

android-drawable ×1