开发者

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 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 ImageViews.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜