How to assign wrap_content as height to dynamically loaded gridview

前端 未结 5 2067
-上瘾入骨i
-上瘾入骨i 2021-01-14 08:31

I am loading gridview dynamically with buttons. So for that I am using scrollview, But if i assign wrap_content as height to gridview all the buttons are not displayed. I do

5条回答
  •  别那么骄傲
    2021-01-14 09:13

    android:layout_height="wrap_content" cannot be used for subclasses of AdapterView (e.g. ListView and GridView). The GridView would have to get each row's height in order to calculate its own height.

    Remove the ScrollView and the LinearLayout, you don't need them. The GridView already has its own scrolling logic built-in.

提交回复
热议问题