Add .setBadge to a ImageView in titanium

I need to add a badge like the added picture. the badge needs to be above an imageView. how can i implement that in Titanium. I'm not using the alloy folder

Answers


@Manuel_Rodrigues. There's no a good way to accomplish the effect you want, but there's a compromise method to get the similar effect. In this way you can consider that the badge is a image too, so just put the badge upon the background image can accomplish the effect. In Titanium, it called MaskedImage which combine too images or just render a image with various blend mode. Well, I don't have a try but maybe it can help you. Check for this link, you'll get more details!


Another simpler solution... Place the Image in a View (we'll call this parent view pView). Make sure pView.layout = 'absolute';

Add the Badge as a Label (we'll call it bLabel) inside pView.

bLabel.width = Ti.UI.SIZE; // so it can enlarge depending on label's text
bLabel.height = 16; // depends on font size
bLabel.borderRadius = 16 / 2; // half the height
bLabel.backgroundColor = 'red';
bLabel.color = 'white';

bLabel.x & y where you want to place this badge within pView, over the Image. If you want the badge to be on top right outside the image, make pView larger than the image.

You may need to hardcode of with & heights of the pView if you're not sure of the height / width of the image (say remote image), you'll have to create the pView and bLabel dynamically on complete event of the image as its being downloaded remotely (we won't know the size of the image till complete is fired).


Need Your Help

What's the meaning of these batch commands?

windows batch-file command-line cmd

I just want to know the meaning of this instructions in detail:

ionic-cache-src not working in android

android ionic-framework image-caching

I want to use image cache in my ionic app, I found ionic-cache-src in google, but after I try use that, that's not working, just show blank rectangle.