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.
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 have a background png in my Android application. I would like to support lots of displays, but I have this one obstacle - many displays have many resolutions and many ratios. I would like to make sure my background is displayed properly and make it more ellegant, than just creating 10+ cropped png files in Photoshop.
My idea would be - a fairly large picture imported in the project. The app would find out screen dimensions and simply say starting points(x,y) and ending points, that would "crop" the picture and display it without any deformations.
Is there a way of doing it?
I think bitmap.createBitmap() is the method your looking after. The method simply lets you cut out a defined portion of the bitmap.
So far, I am able to achieve the default crop options available in the devices. But my requirement is like cropping the image with 4 dots, so that any image can be cropped to any shape.
Any idea , how this can be achived. DocumentScanner application already uses this feature.
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.
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.