Change Height of a Listview dynamicallyAndroid

前端 未结 8 1715
借酒劲吻你
借酒劲吻你 2021-01-06 23:29

The format of my XML file is as following:

 LinearLayout 

     ScrollView

         RelativeLayout

             LinearLayout

             

        
8条回答
  •  北恋
    北恋 (楼主)
    2021-01-06 23:49

    import android.view.ViewGroup.LayoutParams;
    
     ListView mListView = (ListView)   findViewById(R.id.listviewid);
     LayoutParams list = (LayoutParams) mListView.getLayoutParams();
       list.height = set the height acc to you;//like int  200
       mListView.setLayoutParams(list);
    

提交回复
热议问题