问题描述
在我的应用中,我允许用户设置背景颜色和图像.因此,为确保所有必要的信息和图标可见,我使用带不同颜色阴影的文本.通过在xml中设置阴影属性很容易进行设置.
In my app I allow user to set background color and images. So to make sure that all necessary information and icons are visible, I use text with shadow of different color. It is easy to set it by setting shadow properties in xml.
但是,我找不到在矢量可绘制对象上绘制轮廓的方法.我发现了类似的问题,但是答案或多或少是绘制带有阴影的矩形或正方形背景.就我而言,这看起来太难看了.我想勾勒出形状,而不是将背景设置为与阴影成正方形.
However, I could not find a way to draw outline on vector drawable. I found similar questions however the answers are more or less drawing rectangular or square background with shadow. That makes it look too ugly in my case. I want to outline the shape instead of setting background to square with shaddow.
推荐答案
我找到了一个窍门.令人惊讶的是,它非常简单.
I found a trick. Surprisingly it's very simple.
答案1.制作一个可绘制矢量的副本-给它起差异名称.2.更改xml中的高度和宽度
Answer 1. Make a copy of vector drawable - give it diff name. 2. Change the height and width in the xml
<vector **android:height="28dp" android:width="28dp"**
android:viewportHeight="24.0" android:viewportWidth="24.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#56F0FF00" android:pathData="M1,21h4L5,9L1,9v12zM23,10c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.59,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-1.91l-0.01,-0.01L23,10z"/>
</vector>
- 现在将此新可绘制对象设置为背景(如果新可绘制对象的大小小于原始对象,则为前景).确保使用适当的缩放比例,以便获得可绘制的轮廓.
这篇关于如何绘制矢量可绘制轮廓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!