gpt4 book ai didi

Android XML drawable透明渐变不透明

转载 作者:太空宇宙 更新时间:2023-11-03 13:20:06 26 4
gpt4 key购买 nike

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

drawable/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>

layout/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>

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

enter image description here

Play Music 的渐变:

enter image description here

它是透明的。

最佳答案

最可能的答案是你的渐变 View 不与 ListView 重叠 - 换句话说, ListView 在你的渐变之上,渐变 xml 是正确的,它的 View 定位错误。你应该尝试更像这样的东西

<ReltaiveLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

Your litview goes here, with both dimensions match parent

<View
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="25dp"
android:background="@drawable/shadow_up"/>
</RelativeLayout>

关于Android XML drawable透明渐变不透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29669440/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com