0

I have a requirement that the layouts and views into an activity is Dynamically added. The layout creating programmatically. The width and height of all layouts and Views are need to be relative to the screen width and height. For example if the height of a Layout to be added is say 50%, then the 50% of screen height ( 50% 1280 in Pixel, in case of Nexus 4) should set as the height of layout. I have an outer scroll view also to view the Views added beyond the screen.

My problem is if I created a layout with 100% screen height and width, then programmatically I am setting the height of layout as 1280 pixels, and width 768 pixels (e.g. Nexus 4,768*1280), logically the added layout should fit the device's screen. No scroll should enable. But in my case scroll view is coming. When I hardcoded the value for a layout width = 768 and height = 1280, it starts scrolling. How can I achieve the height and width to the views relative to the device's screen.

I am getting the real height and real width of device from here link

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Arundas K V
  • 801
  • 2
  • 14
  • 28

0 Answers0