RelativeLayout Programmatically in Android

This article aimed at understanding how we can implement RelativeLayout programmatically. We can initialize the layout normally like

RelativeLayout layout = new RelativeLayout(this);

To position the child to left, right, top or botttom, we have to add rules to the layout params as,


params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);

Comments

Popular posts from this blog

AlarmManager and Notification in Android

Swipe Action and ViewFlipper in Android