Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to hide a view when there is not enough room for it

Let's imagine I put 10 ImageViews into a LinearLayout. On some phones, the screen is too small, only 9 could fit. The 10th will be smaller.

Is there a way to hide the 10th if there is not not enough room on the screen?

like image 235
vieux Avatar asked May 27 '11 16:05

vieux


1 Answers

Yes, it is possible. You can get the Height of your screen, and then add an image and calculate the height sum of all the images you added, and compare, if (sumHeightImages >= screenHeight) : then set the visibility of the rest images to GONE :)

like image 126
Houcine Avatar answered Nov 02 '22 21:11

Houcine