简体   繁体   English

如何反转(负)Android矢量图像(路径)

[英]How to Invert (Negative) Android Vector Image (Path)

Need area bound by Vector to be transparent and background (Remaining area) to be filled. 需要由Vector绑定的区域是透明的,并且要填充背景(剩余区域)。 Required to make it easy to dynamically fill color of vector (Toggle Button Drawable) when the same is bound by a Selector 当通过选择器绑定矢量时,使其易于动态填充矢量颜色(切换按钮可绘制)

I Have Vector Path for Below generated from Studio: (Amber space is Transparent) 我有从Studio生成的下方矢量路径:(琥珀色空间是透明的)

在此处输入图片说明

I want This: (Amber space is Transparent) 我想要这个:(琥珀色空间是透明的)

在此处输入图片说明

Thanks to @pskink - Per his suggestion I used 感谢@pskink-根据我的建议

myImageView.setColorFilter(Color.WHITE, PorterDuff.Mode.XOR);
myStateListDrawable.addState(new int[] { android.R.attr.state_checked },  myImageView);

To achieve my needs. 达到我的需求。

Scroll down the below link - there are easy to understand examples with other options for ColorFilter 向下滚动以下链接-易于理解的示例以及ColorFilter的其他选项

https://android--examples.blogspot.in/2015/11/android-color-filter-and-different.html https://android--examples.blogspot.in/2015/11/android-color-filter-and-different.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM