Code example for RelativeLayout

Methods: addView, setBackgroundColor

0
    protected void onCreate(Bundle savedInstanceState) {
         
    	super.onCreate(savedInstanceState);
    
    	 
    	RelativeLayout layout = new RelativeLayout(getContext());
        layout.setBackgroundColor(0xFFFFFFFF);
    	 
        setupWebView(layout);        
        setupProgress(layout);
         
         
        FrameLayout.LayoutParams FILL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
        addContentView(layout, FILL);
         
         
    } 
 
    private void setupProgress(RelativeLayout layout){
    	 
    	Context context = getContext();
    	 
    	ll = new LinearLayout(context);
    	 
    	ProgressBar progress = new ProgressBar(context);
    	int p = AQUtility.dip2pixel(context, 30);
    	LinearLayout.LayoutParams plp = new LinearLayout.LayoutParams(p, p);
    	ll.addView(progress, plp);
    	 
    	if(message != null){
	    	TextView tv = new TextView(context);
	    	LinearLayout.LayoutParams tlp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	    	tlp.leftMargin = AQUtility.dip2pixel(context, 5);
	    	tlp.gravity = 0x10;
	    	tv.setText(message);
	    	ll.addView(tv, tlp);
    	} 
    	 
    	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 
    	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    	 
        layout.addView(ll, lp);
    	 
    } 
     
    private void setupWebView(RelativeLayout layout) {
    	 
    	wv = new WebView(getContext());
    	wv.setVerticalScrollBarEnabled(false);
    	wv.setHorizontalScrollBarEnabled(false);
         
        if(client == null) client = new WebViewClient();
         
        wv.setWebViewClient(new DialogWebViewClient());
         
        WebSettings ws = wv.getSettings();
        ws.setJavaScriptEnabled(true);
        //ws.setSaveFormData(false); 
         
        //wv.loadUrl(url); 
         
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);       
        layout.addView(wv, lp);
         
         
    } 
     
    public void load(){ 
Experience pair programming with AI  Get Codota for Java