android - 如何使基于角的渐变可绘制
问题描述
我正在尝试制作仅放置在右下角的渐变背景。(对不起图片,因为我没有足够的内联代表)
https://i.stack.imgur.com/ebgWn.jpg
首先,我做了径向渐变,但并不完美
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerX="0.9"
android:centerY="1"
android:endColor="#00000000"
android:gradientRadius="40%p"
android:startColor="#BF000000"
android:type="radial" />
</shape>
看起来像:
https://i.stack.imgur.com/JOqFf.jpg
然后,我做了线性渐变,但仍然不完美。
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="315"
android:endColor="#CD000000"
android:startColor="#00FFFFFF"
android:type="linear" />
</shape>
https://i.stack.imgur.com/a0y9C.jpg
因为gradientRadius参数不适用于线性渐变。此渐变是否有任何起点/终点参数?感谢帮助!
解决方案
我试过的最好的
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:centerX="0.8"
android:centerY="1"
android:endColor="#00000000"
android:gradientRadius="80%p"
android:startColor="#BF000000"
android:type="radial" />
然后将你和 Tick Icon 包装TextView
在一个布局中,并将上面的背景设置为它..
如果您想要与图像中提供的完全相同的效果,那么您最好使用图像或矢量文件。但方法是将背景设置为仅包裹布局而不是根。
推荐阅读
- go - How to count the number of goroutine in runnable state
- javascript - 如何在中心模式下创建 Slick Slider JS 幻灯片
- angularjs - 如何销毁/清理现有的控制器?
- owl - OWL:属性的逆
- xcode - macOS 命令行应用程序 - 用户默认值 dictionaryRepresentation 显示太多值
- javascript - 如何跟踪页面上 DIV 的存在?
- javascript - Mapbox单击多边形不会产生弹出框
- multithreading - 用于 CPU 密集型应用程序的多线程与多进程设计方法
- flutter - 如何将物品堆叠在一起?
- bootstrap-modal - 如何使用 jQuery 打开 Bootstrap 模式?