Code example for RelativeLayout

Methods: setLayoutParamsaddView

0
	}	 
	 
	public View showActionBar(Activity parent, View original, Entity entity, ActionBarOptions options, ActionBarListener listener) {
		RelativeLayout parentRelLyout = newRelativeLayout(parent);
		RelativeLayout.LayoutParams barLayoutParams = newLayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		parentRelLyout.setLayoutParams(barLayoutParams);
		 
		ActionBarView socializeActionBar = newActionBarView(parent);
		socializeActionBar.setActionBarListener(listener);
		socializeActionBar.assignId(original);
		socializeActionBar.setEntity(entity);
		socializeActionBar.setActionBarOptions(options);
		 
		LayoutParams socializeActionBarParams = newLayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		socializeActionBarParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
		 
		socializeActionBar.setLayoutParams(socializeActionBarParams);
		 
		boolean addScrollView = true;
		 
		if(options != null) {
			addScrollView = options.isAddScrollView();
		} 
		 
		View contentView = null;
		 
		if(addScrollView && !(original instanceof ScrollView) && !(original instanceof ListView) ) {
			RelativeLayout.LayoutParams scrollViewParams = newLayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
			 
			scrollViewParams.addRule(RelativeLayout.ABOVE, socializeActionBar.getId());
			 
			ScrollView scrollView = newScrollView(parent);
			scrollView.setFillViewport(true);
			scrollView.setBackgroundColor(Color.parseColor("#00000000"));
			scrollView.setScrollContainer(false);
			scrollView.setLayoutParams(scrollViewParams);
			scrollView.addView(original);
			 
			contentView = scrollView;
		} 
		else { 
			ViewGroup.LayoutParams originalParams = original.getLayoutParams();
			LayoutParams updatedOriginalParams = null;
			 
			if(originalParams != null) {
				updatedOriginalParams = newLayoutParams(originalParams);
			} 
			else { 
				updatedOriginalParams = newLayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
			} 
			 
			updatedOriginalParams.addRule(RelativeLayout.ABOVE, socializeActionBar.getId());
			 
			original.setLayoutParams(updatedOriginalParams);
			 
			contentView = original;
		}		 
 
		parentRelLyout.addView(contentView);
		parentRelLyout.addView(socializeActionBar);
		 
		return parentRelLyout;
	} 
	 
	protected LayoutParams newLayoutParams(int width, int height) {
		return new LayoutParams(width, height);
	} 
	 
	protected RelativeLayout.LayoutParams newLayoutParams(android.view.ViewGroup.LayoutParams source) {
		return new RelativeLayout.LayoutParams(source);
	} 
	 
 
	protected RelativeLayout newRelativeLayout(Activity parent) {
		return new RelativeLayout(parent);
	} 
 
	protected ScrollView newScrollView(Activity parent) {
		return new ScrollView(parent);
	} 
Experience pair programming with AI  Get Codota for Java