Question

enter image description here

I want to define the contentArea of a Frame/Linear/Relative layout so that when I do layout.addView(view); it only added within the boundries and the rest of the view is clipped away. Like the picture of shirt, if I want to define the boundries of shirt to be the area of content...how can I do that. Any suggestions/help? Thanks

PS: cannot do that in 9-patch (right and bottom) as it only defines in rectangular shape, in this case shape can be anything like that of a shirt. Want to omit the white/transparent part from the contentArea.

Was it helpful?

Solution

try the below code :- Just in case someone is trying to solve same problem, there is a better solution: Bitmap.createBitmap(Bitmap, int x, int y, int width, int height). For example, if you need to crop 10 pixels from each side of a bitmap then use this:

Bitmap croppedBitmap = Bitmap.createBitmap(originalBitmap, 10, 10, originalBitmap.get

OTHER TIPS

That's not really something you can do. From what i understand you can't use PorterDuff because you need to add views to this clipped container. I would suggest an easy trick that might be useful for u. Just add an imageview on top of your Frame/RelativeLayout that has as content an image with a full transparency on the part you want to be visible and it's opaque in the area u want to clip. Graphically speaking that way you should achieve exactly what u need.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top