How to set Button "Layout below" properties by code in android inside an Relativelayout i have defined relative layout by using findview开发者_运维问答by id.
use addRule() of LayoutParams to set layout below
RelativeLayout.LayoutParams lineParams = new RelativeLayout.LayoutParams(
android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT,
android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
lineParams.addRule(RelativeLayout.BELOW, myview.getId());
Add this button to RelativeLayout which is defined
Relativelayout rl= (RelativeLayout) findViewById(R.id.Relativelayout01);
rl.addView(b,lineParams);
精彩评论