Android Question Adjust scrollView height based on screen size?

bryantm1122

Member
Licensed User
Hello,

I have a scrollView that needs to change height when focus is on editText fields. I've worked that part out, but when I test on different screen sizes, the scrollView's new height doesn't work on < 5" screens. I'm testing on a Note4 with a 5.7" screen and 560dpi. Also testing on an HTC One with a 4.7" screen and ~460dpi.

Using this code from Erel's ActionBar tutorial as an example:
cJNalnY.jpg


is there a way to find out the screen size programmatically, so I can then resize the scrollView as needed?

I've tried this:
B4X:
Sub CalculateHeight
  If 100%x >= 480dip Then
    Return 1500  'scroll.Height for 5" + screens
  Else
    Return 1200 ' scroll.Height for 4" + screens

It doesn't work.

If I understand Erel's code correctly, the 100%x is the width as it relates to the pixel density, and not the physical width of the screen. Not sure if I need the dpi or physical width.

I appreciate any help with this, or advice to go in a different direction.

Thanks!
 
Top