Nop*_*ius 12 android dynamic button
我有一个动态布局,我有一个按钮.如何将属性layout_alignParentBottom设置为该按钮,以便它显示在我的相对布局的底部?
或者你知道另一种方式吗?
Kev*_*ead 54
这仅在您的布局是RelativeLayout时才有效,因为其他ViewGroup不了解alignParentBottom.
RelativeLayout layout = findViewById(R.id.my_relative_layout);
Button button = new Button(this); // your button
lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); // You might want to tweak these to WRAP_CONTENT
lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layout.addView(button, lp);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12987 次 |
| 最近记录: |