📌  相关文章
📜  如何以编程方式在 android 中设置布局参数 - Kotlin 代码示例

📅  最后修改于: 2022-03-11 14:53:34.324000             🧑  作者: Mango

代码示例3
yourView.setLayoutParams(new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT
                    //change the parameters as whatever you want
            ));
//keep in mind that LinearLayout is not the only Layout, e.g. you can use ConstrainLayout etc...
//after, you need to add yourView to a layout as it won't redraw itself if you just change the layout parameters e.g.:
yourLayout.addView(yourView); //yourView will pop on yourLayout