in my android application, I want to display some images of plants (i have more than 100 of them) a i also want to support different screen sizes, but my problem is i can not have images for every screen density in res/drawable folder, because size of my application horribly increase. Is there any solution how to do this? (maybe in code) Thanks a lot.
From what I understand, you want to have the text wrap around the image. You could best achieve this using this library.
As for the images, you would only need to store them at a size that looks good on the largest devices you are looking to support. For the other devices, you would just scale those down. If you're going to use the above library, you might need to set the following parameters on the ImageView in the XML file to have it scale down correctly:
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
Note that you will need to fiddle around with these (especially the weight) so that you get the best fit for your application.
EDIT: To conform to your requirement in the comment, the best way to go would be to use a WebView. This does mean you will need to create HTML code for your articles, which would completely change the question.
What you could try is to have a LinearLayout surrounding the image and add TextView objects to it programatically. There are good chances that this will look bad depending on the amount of text you will be adding.
Related
First situation
Let's say I have a screen with several buttons placed in vertical order.
I distributed available space between them using weights.
So, on a large screen buttons get bigger. That's what I want.
But how I make the text look bigger to?
Okay, I took a class from here Auto-fit TextView for Android.
But is that normal that android does not have a standard approach for this and we have to use a custom class?
That's weird. How do developers deal with it?
Second situation
Let's say it's okay to use this custom class.
I have a ListView
I want the items to increase their height as the height of screen increases.
How do I do that? I found a difficult way to do that, but it all seems like lots of troubles.
How do developers usually do such things?
Or maybe developers don't resize list items at all?
Maybe it's okay if they are set in dp and look quite small on big tabs?
I'm adding this as answer because I did a lot of typing.
If you're using Eclipse, you'll see that there are a number of folders in Drawables. They are essentially for sm, md, lg, xglg, etc... All screens fit into one of those categories. What people normally do is design a layout for each. And, yes, there are hundreds of individual sizes. And yes, it's a pain to create for all of them. But many developers do exactly that. And don't forget about landscape and portrait. Need layouts for those too.
I need to put together a complete image, as seen here. Each piece of the segmented tree is an individual image, but I am unsure about how I should put the pieces together efficiently with spacing in between. I've thought about stacking the images on top of each other one at a time within a canvas, but I have my doubts as to whether this is the approach that I should take. Is there a different type of container I should use or a better method of accomplishing the same task?
EDIT: just to clarify, I need to assemble the image programmatically, beginning with the base segment and eventually ending with the top segment.
If you use a program like Gimp, you can added each image as a layer, then move the layers around correctly. I'm not quite sure how you want to represent the space between the segments, transparent?
Any way after you have your image assembled the way you want you can either merge the layers or save it to a format that will flatten out your images.
I'm not sure if you want your image to be able to stretch at all or not. If so, you can save it as a .png file and then use draw9patch or equivalent to add in stretching segments. Also I'm not sure if you have to support multiple drawable sizes, if so I have a free Android app, DP Image Calculator on Google Play that might help. Just remember start with the highest resolution and work you way down to the smallest.
Hope this helps. If you have more question let me know. Have a great day.
I am developing a simple game part of application where i need to create a game using lots of images of different different shapes, imagine ice breaker game where i need to break ice using hammer.
So when i think of setting layout with different types of ice images and that too which support all different densities,i get stuck and not able to understand how i set my layout, whether with Relative / Linear Layout so that it give me same result in all size of android devices except tablets.
I hope you understood the problem, support of all density, around 500-600 images with different shapes, which layout to use and one more thing .apk size is also big matter for me as there are other lots of images other than for this game.
Please read the Screen Supports for the better understanding.
Use configuration qualifiers as explain in that Document for the Different Layout. And Also put the XML file with in that layout drawable directory.
that help me. So it will be also helpful to you.
Be free to comment if you have any dought.
Edited
You can set the layout for the different screen support as like below:
See the Image Below:
I read a topic about multiple screen support, but I don't understand why I need a different picture for every screen size if I can stretch image by setting
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bk"
for every screen.
You don't have to have a different image for each screen size. You certainly can just use fill_parent and just use the same image. The only issue is that it usually won't look as good. In fact, in some cases it will look absolutely terrible. Assuming that you're fine with your image being stretched though, you can just use one image.
If your background image is not a plain image, and has a lot of detail, then it renders better if it is the exact size needed. Shrinking a large image to small may make it look grainier than you want.
However, you can still do it. Make sure to make AVDs with different screen sizes, so you can see how it might look.
I am creating an application which on one view has an image of an elephant. this elephant needs to animate various parts of his body such as eyes, trunk, spraying water, and also the background/horizon movements. I have briefly tried positioning each element(eye, trunk, etc) in a RelativeLayout using margins and relative positions so that the picture looks correct.
When i change the screen size via eclipse layout editor everything gets out of place. I read that using RelativeLayout with margins and relative positions will be the best alternative to AbsoluteLayout, but i can't seem to get each piece in the right spot while keeping some compatibility of devices.
What is the best way of positioning pieces of the image to complete a full image which will also allow me to animate/translate/rotate/etc each piece and support a large variety of devices?
I thought that maybe using OpenGL or Canvas might be the way this is done properly, but i don't see how these would resolve the problems i've mentioned.
I have created the iOS version of this application and it was extremely easy to set this up. I don't quite understand how applications line up sprites to make a scene which is compatible among a large variety of screen sizes/densities.
You will have to scale the elements of your big picture to fit the High , medium and low screen densities .
To do this you will have to resize each set of elements and copy them into separate drawable folders :
/res
drawable-hdpi
drawable-ldpi
drawable-mdpi
also you can create a dedicated layout for each screen category if needed but first try just to scale the images and copy them into the folders and launch your application.
A good link to see also : http://developer.android.com/guide/practices/screens_support.html
P.S: make sure to use dp not pix as measurement unit on your layouts , also the use of absolutelayout is not a good choice it's deprecated.