android - 如何在Android中添加完全透明到半透明的渐变
问题描述
我有一种情况,我想添加一个图像视图,效果与此应用程序相同
正如您所注意到的,有一个可绘制或隐藏视图底部的东西添加了透明渐变。我怎样才能达到同样的效果?
解决方案
将此drawable放在布局的底部:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FFFFFF"
android:endColor="@android:color/transparent"
android:angle="90" />
</shape>
你的布局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >
<View
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="@drawable/gradient"
android:layout_gravity="bottom"/>
</FrameLayout>
推荐阅读
- python-3.x - 使用 python + selenium 下载 pdf 文件的问题
- java - 实现分支逻辑时跨Flowables取消
- javascript - 无法注入
- postgresql - 在 Postgres 中创建函数时出错
- django-taggit - Django-taggit 使用选择下拉菜单
- c# - Cefsharp 平滑滚动?
- php - 使用 Homestead Web 服务 - 我无法将 PHP 脚本移动到服务器文件管理器中?(错误 0x39)
- html - 字体真棒图标未通过 cdn.fontawesome.com 呈现
- php - 有没有办法删除传输到另一个选项卡的数据?避免在同一页面中重复?PHP 代码点火器
- javascript - 检测 div 上的“手动”水平滚动