Android how to set image + text + button properly


I have a vertical linearLayout. From top to bottom it contains: image, static text and then a button.

The image’s original size is very big, 2000px high, i want all three things to fit in the viewport without having to scroll. Which would be the best way to achieve this?


You can set this in two ways:

  1. a.You can give static height and width to your image in your xml file and then adjust text and button below it accordingly.
    b. You can get height and width of your android device, then set the height and width as per the dimensions you get at runtime for adjusting your views.
  2. Another way for implementing this is that you can resize your image according to hdpi, mdpi,xhdpi,xxhdpi(as per their standard sizes). Then reset your views.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.