Android - How do I specify weight programmatically for a RelativeLayout?

前端 未结 1 404
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 04:54

I want to do something like this programmatically -


  
  
  

        
相关标签:
1条回答
  • 2020-12-16 05:14

    When you add the RelativeLayout to the LinearLayout using addView you have to provide a LinearLayout.LayoutParams, something like this :

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height, weight);
    linearLayout.addView(relativeLayout, params);
    

    Reference here

    0 讨论(0)
提交回复
热议问题