Code example for RelativeLayout

Methods: setGravity, addView, setId

0
			params.addRule(RelativeLayout.CENTER_VERTICAL);
		} 
		params.setMargins(0, 0, 5, 0);
		layout.addView(leftImage, params);
 
		RelativeLayout textLayout = new RelativeLayout(getContext());
		textLayout.setGravity(Gravity.NO_GRAVITY);
		textLayout.setId(101);
 
		title = new TextView(context) {
 
			@Override 
			protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
				super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 
				if (getMeasuredWidth() > 230) {
					setMeasuredDimension(200, getMeasuredHeight());
				} 
			} 
 
		}; 
		title.setId(200);
		title.setTextColor(Color.argb(255, 216,216,216));
		title.setTag("title");
		TiUIHelper.styleText(title, "sans-serif", "15sip", "bold");
		params = createBaseParams();
		params.addRule(RelativeLayout.ALIGN_TOP);
		textLayout.addView(title, params);
 
		snippet = new TextView(context);
		snippet.setId(201);
		snippet.setTextColor(Color.argb(255, 192,192,192));
		snippet.setTag("subtitle");
		TiUIHelper.styleText(snippet, "sans-serif", "10sip", "bold");
		params = createBaseParams();
		params.addRule(RelativeLayout.BELOW, 200);
		textLayout.addView(snippet, params);
 
		params = createBaseParams();
		params.addRule(RelativeLayout.RIGHT_OF, 100);
		params.addRule(RelativeLayout.ALIGN_TOP);
		layout.addView(textLayout, params);
Connect your IDE to all the code out there  Get Codota for Java