Alex Rivera | Logout

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

Asked 2011-05-27T16:15:46.300
9

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?

Edit
Report

1 Answer

1

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 :)

answered 2011-05-27T16:21:56.003

Your Answer