how to streatch small image with out losing its quality - android

In my app i have to set up a small image as background, to show text and image on it.
1)I tried to set image as background of a layout some thing like
<layout android:background="imagePath"> <ImageView/> <TextView/></layout>
2)Tried to show image in web view.
But the image has lost its quality. In iphone we can resiz it like stretchableImageWithLeftCapWidth:23.0f topCapHeight:15.0
i want to know what should be the best method for image resizing in android

Best way to do stretchable background is 9-patch drawable. Android sdk provides instrument for simple creating 9-patches.
Using this you have to manage part of Image which not losing quality.

Best way to do stretchable background is 9-patch drawable. Android sdk provides instrument for simple creating 9-patches.

Related

Skip transparent background in an image when setting an image as background in android

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!

rectangular box with one side diagonal

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.

android background image scale by cropping

I want to add a background image to my layout by adding a big image and then set android dynamically crop my image from center for different android devices. I have tried lots of ways but i cant find any way of doing this specific job.

Create custom Imageview component that has a custom picture frame

I would like to build a custom component (extending from ImageView I guess) that display an image inside a frame specified by the user (the frame is a custom image) with inner rounded corners (Pinterest user icon like).
I started finding how to compose two bitmaps but it is a difficult matter so I am wondering if there is some opensource component/tutorial to better understand how to achive it.
The frame picture is a nine-patch png (I didn't understand how to load and scale it properly into a bitmap).
Thanks
Have you checked out this
Seems like it does the job, although I'm not sure how to implement.

Cropping large background image

I have two situations/projects where I have to use a large bitmap as background activity.
The first project ports a WP7 application to Android! The WP7 app is using a panorama control with a bitmap as large as 3 screens. I would like to reuse the large bitmap similar in a way that I use the left part for the first activity, the middle part for the second activity and the right part for the third activity. In other words I would like to define which part to crop.
In the second project we try to develop an app which should run on various screen sizes (including tablet), the app should also use a background image. Is it a good idea to provide only one picture with a quadratic size (as long as the largest screen width) and use this picture through every resolution and just crop the background image depending on the actual size of the display?
Is it possible to crop pictures on Android?
Is it possible to define the part of the picture which is kept?
Is it possible to use this croped pictures as background image or may I encounter performance penalties?
What do you think of this technique? Is it a good idea?
Thanks for your help!
answering your questions:
yes it is possible to crop pictures in Android (I've done so)
you can define wich part of the picture is shown in each activity
with a canvas and only drawing the rect that corresponds to the part
of the image that you want to display (eventough I wouldnt suggest
the approach of having diferent activities with the "same" content)
yes, you can use cropped pictures as background image for whatever
you want. Once you cropped the image use that bitmap and save it in
the device and then you might use it as you wish, and eventought is not recommended to have the whole image as background you can do so.
I suggest that you use a SurfaceView since you will be able to move it (the image) all around the screen without having to create a new activity. Here is a good tutorial to SurfaceView Playing with graphics in Android – Part I and this approach will also work with Tablets.

Categories

Resources