Is there a way to hide a view when there is not enough room for it
Let's imagine I put 10 ImageView
s into a Linea开发者_如何学PythonrLayout
. 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?
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 :)
Use a ScrollLayout
with the nested LinearLayout
that contains the ImageView
s.
精彩评论