문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top