Code example for RelativeLayout

Methods: addView, setId, setOnClickListener, setPadding

0
		super(context, attrs, defStyle);
	} 
 
	@Override 
	protected View onCreateView(final ViewGroup parent) {		
		final RelativeLayout layout = new RelativeLayout(getContext());
		layout.setPadding(15, 5, 15, 5);
 
		 
		 
		//setup title 
		final RelativeLayout.LayoutParams titleparams = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		titleparams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		titleparams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
 
		final TextView title = new TextView(getContext());
		title.setText(getTitle());
		title.setTextSize(24);
		title.setTextColor(Color.WHITE);
		title.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
		title.setGravity(Gravity.LEFT);
		title.setLayoutParams(titleparams);
		title.setId(TITLE_ID);
 
		layout.addView(title);
		layout.setOnClickListener(this);
		layout.setId(android.R.id.widget_frame);
 
		return layout;
		 
		 
	}