0

I have an ImageView in Android with a foto in it. That view should always have the same proportions no matter which device it is displayed on. In my example the width of the ImageView is 427 dp and the height is 250 dp. I choose this special width to make the picture cover the whole width of the layout in Android studio. Now my question is, how should I modify the raw pictures taken from my camera (or whatever device/tool) such that it fits to the desired proportions? I mean, the raw picture does not have the desired proportions. This is why I extracted an ereas out of the picture with the desired proportions. I could specify the pixels for that in the tool I use (IrfanView). The proportions shoudld be multiples of 427 and 250, meaning that the following options are possible (427, 250) (2 * 427,2 * 250) (3 * 427, 3 * 250) etc. Now I do not know what size to choose. The ImageView might need different proportions depending on the device it is displayed on. Does someone have a good advice how to do that. Here you see a screenshot of the ImageViewenter image description here

Update: As nobody has answered so far, I would like to ask you again, how I should decide about the size of pictures in Android given that the app would run on different devices with different screen sizes. What is your way of deciding about that?

I'd be happy for every comment

Update 2: Can nobody help me with that? This should be a common problem. I mean you create an app for different devices and you need a picture for that app. What size should the picture have.

Why does nobody answer? Is the question itself unclear? If so please tell me.

VanessaF
  • 515
  • 11
  • 36
  • You can use layout_constraintHeight_percent – Rajnish suryavanshi Jan 11 '20 at 15:46
  • Thanks Rajnish for your comment. My question was on how to adjust the raw picture such that it fits the predefined area without the picture being scaled in a bad way. What resolution should the picture in teh android app folders have? – VanessaF Jan 11 '20 at 16:56
  • ???????????????? – VanessaF Jan 16 '20 at 20:58
  • Try different scale type which fits the best to you. I think the center should work for you as it centered in the view with no scaling. – Rajnish suryavanshi Jan 17 '20 at 08:31
  • Thanks Rajnish for your answer. As said before, the problem is that I need different scales types for different devices I think. Let's say I have a certain foto and I would like that it covers a certain part of the screen (as in my example). Now if I use a big tablet I surely need another resolution compared to displaying the picture on a small phone. How can I do that? – VanessaF Jan 18 '20 at 11:40
  • @Rajnishsuryavanshi: What do you mean by saying "the center should work for you " – VanessaF Jan 18 '20 at 11:41
  • @Rajnishsuryavanshi: How can I manage the dependecy of the correct resolution on the device. – VanessaF Jan 21 '20 at 20:19
  • Any ideas how I can do that? – VanessaF Jan 25 '20 at 09:10
  • @Rajnishsuryavanshi: As nobody else has answered my question other than you, I would like to try your suggestion. But would you mind elaborating a little bit more on that? What do you mean with "think the center should work for you as it centered in the view with no scaling" and how does this solve my basic problem? – VanessaF Feb 02 '20 at 11:06
  • Can nobody help me with that? This should be a common problem. I mean you create an app for different devices and you need a picture for that app. What size should the picture have. – VanessaF Feb 08 '20 at 10:59
  • Why does nobody answer (or why Rajnishsuryavanshi not anymore)? Is the question itself unclear? If so please tell me. – VanessaF Feb 10 '20 at 20:49

1 Answers1

2

try this i think you need two define two dimen files. one for normal phone and one for tablet. One size define in all dimen files. if you load in mobile normal fonts which you define for mobile will be load, if tab then tab font size.

How to define dimens.xml for every different screen size in android?

nafees ahmed
  • 948
  • 1
  • 12
  • 18
  • Thanks nafees for your answer. So I should define different pictures for different resolutions. Where shall I put them (in which folder) and what does a dimension file here contain? How can I write such a file? – VanessaF Feb 14 '20 at 21:59
  • where shall I save the different pictures? In the dimesion folder? But how shall I label them such that Android knows which one to choose? – VanessaF Feb 15 '20 at 17:53
  • you can define the sizes of imageview's height and width wrt phone and tablet.. but you cannot control the size of picture.. – nafees ahmed Feb 16 '20 at 06:03
  • Thanks nafees for your answer. But can I not just save different formats of the pictures and android chooses the one that fits best to the current display? Or is it common to just use one picture with a high resolution for every device? – VanessaF Feb 16 '20 at 11:18
  • you can reduce the picture quality reduce it to 25, Its common to use one picture. – nafees ahmed Feb 16 '20 at 18:14
  • Thanks nafees for your comment. I do not understand why I can reduce the picture quality to 25. What does that basically mean? Surely, it depends on the picture to what degree you can reduce it – VanessaF Feb 17 '20 at 19:42
  • imageToSave.compress(Bitmap.CompressFormat.PNG, 25, out).. I am talking about this line. – nafees ahmed Feb 18 '20 at 06:24
  • Thanks nafees for your comment: In which folder shall I save the picture? – VanessaF Feb 18 '20 at 20:53