I want to repeat specific rectangular area at centre of png drawable instead of repeating the whole image using
android:tileMode="repeat" . If I 9 patch it will get stretched .any solution ?
Either, offline create a new PNG that only consists of the area you want, or dynamically, create a new Bitmap from the area you want and use this image for a drawable.
Related
I am working on a project in which I am using a lot of images. My friend has designed all the images in photoshop and all those images are of my required size.
But the problem is that when my friend exported those images from the photoshop, he exported those images with a transparent background and that transparent background with the image makes the frame size bigger than required. And when I set that image to some ImageView, it expands to the whole screen due to its bigger frame size.
Now my question is that Is there a way to set image in imageview so that the transparent part is automatically ignored and the image of my required size just sets into the imageview. Or It is required to crop those images in photoshop and then use those images.
I am sorry if someone couldn't understand the question but I can elaborate if asked.
The way I would do it would be just edit them in photoshop, but I found another way if you want to look into it. Its called webP and you can check it out here. With this you can skip the transparency, but I think the size would stay the same, You can try it out if you want though.
Hope this helps!
I want to create a custom View similar to this image. More specifically, the dark "number of riders" view. I don't want to use an image for background. I need a drawable xml for the background.
I am new to Android so any help would be appreciated.
The best way to do that will be to use a 9-patch drawable file and set it as the background of the TextView.
Here is how you can do that: http://en.miui.com/thread-26099-1-1.html
Or you can create an SVG and use that as background. The easiest way to do that would be to make a png image and convert it to SVG file using online converters.
How to convert a PNG image to a SVG?
There is more complicated way to archive it like drawing on a canvas and using that as background, But I would recommend you to use 9-patch file.
I want to get the part of an image which is visible to us. There is another image over the first image. So from that image, some part of first image is visible. And I want that part only.
I’ll show you sample of it and final output which I am expecting from it.
I know how to crop in oval shape. But here, the template used in above example can be different in actual, so as per the template /mask I need to crop that image.
How can I do this. Any idea?
A simple but maybe not very efficient solution:
assume the mask is above the real image
both images are in the same container and if the mask is above the image this means that the pixels of the image would correspond to pixels of the mask
draw only those pixels of the image whose corresponding pixel in the mask is not black
so I'm trying to find the region of the current image in the ImageView and fill that region with a different image. Here is the original image Empty Circle inside an imageView. The imageView has a drawable of a circle inside. Then I'm trying to make it into something like this Circle filled with image inside an ImageView when a user chooses an image. I don't want to manually Photoshop a circle image. I am just hoping to fill the region with another image. I have tried SRC_IN method from AlphaComposite, but for android, I can't convert from BitMap to graphics2D. If anyone knows how to solve this using the BitmapFactory in android, I would really appreciate your help. Thank you.
The other solution besides Bitmaps, may be too simple for whatever you are trying to achieve otherwise I think it would have occurred to you. I'm just pointing it out in case you have "code blindness" and are trying to over-engineer the solution because you've worked on it for too long (we've all done it)
It is to have that circle/shape image saved as a png with the area you want filled being transparent then set it as the drawable for an ImageView (etc.) then in a RelativeLayout lay this view over the image you want to fill the area and apply a transparent background to the shape view OR simply set the fill image as the background for the shape view.
I would like to create Drawable that contains nine-patch and a Bitmap.
I put them together in Layer List Drawable, but it turns out that Bitmap is extending nine-patch beyond the edge.
Is there any way to "cut" Bitmap so it won't be overlapping nine-patch?
EDIT: Actually it seems that I would like to shrink background to wrap content and ingore big bitmap in background.
a nine patch by definition doesn't have a size.
From the sounds of things you haven't configured your nine patch correctly.
Please attach an image of what you're seeing and your source files.