how to set height of gridview programmatically android

前端 未结 2 1188
你的背包
你的背包 2021-02-05 11:40

I want to set the height of my Gridview programmatically in my application.

Is there any way to implement that?

I just want to change the gr

2条回答
  •  情书的邮戳
    2021-02-05 12:01

    I think this should work:

    GridView gridView = (GridView)findViewById(...);
    ViewGroup.LayoutParams lp=new ViewGroup.LayoutParams(width,height);
    gridView.setLayoutParams(lp);
    

提交回复
热议问题