简体   繁体   中英

How to Invert (Negative) Android Vector Image (Path)

Need area bound by Vector to be transparent and background (Remaining area) to be filled. 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)

在此处输入图片说明

I want This: (Amber space is Transparent)

在此处输入图片说明

Thanks to @pskink - Per his suggestion I used

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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