Code example for RelativeLayout

Methods: setGravity, addView, setBackgroundDrawable

0
dismiss();
	} 
 
	private void setUpWebView() { 
		webViewContainer = new RelativeLayout(getContext());
		mWebView = new WebView(getContext());
		mWebView.setVerticalScrollBarEnabled(false);
		mWebView.setHorizontalScrollBarEnabled(false);
		mWebView.getSettings().setJavaScriptEnabled(true);
		mWebView.setWebViewClient(new WeiboDialog.WeiboWebViewClient());
		mWebView.loadUrl(mUrl);
		mWebView.setLayoutParams(FILL);
		mWebView.setVisibility(View.INVISIBLE);
		 
		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.FILL_PARENT);
		 
		RelativeLayout.LayoutParams lp0 = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);
		 
        mContent.setBackgroundColor(Color.TRANSPARENT);
        AssetManager asseets=WeiboDialog.this.getContext().getAssets();
        InputStream is=null;
        try { 
             try { 
               is=asseets.open("weibosdk_dialog_bg.9.png");
               DisplayMetrics dm = this.getContext().getResources()
                       .getDisplayMetrics();
               float density=dm.density;
               lp0.leftMargin =(int) (10*density);
               lp0.topMargin = (int) (10*density);
               lp0.rightMargin =(int) (10*density);
               lp0.bottomMargin = (int) (10*density);
           } catch (Exception e) {
               e.printStackTrace();
           } 
             if(is==null){
                     //webViewContainer.setBackgroundResource(R.drawable.weibosdk_dialog_bg); 
             } 
             else{ 
                   Bitmap bitmap = BitmapFactory.decodeStream(is);
                   NinePatchDrawable npd=new NinePatchDrawable(bitmap, bitmap.getNinePatchChunk(), new Rect(0,0,0,0), null); 
                   webViewContainer.setBackgroundDrawable(npd);
             } 
        } catch (Exception e) {
            e.printStackTrace();
        }finally{ 
            if(is!=null){
                try { 
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                } 
            } 
        } 
        
		 
        webViewContainer.addView(mWebView,lp0);
		webViewContainer.setGravity(Gravity.CENTER);
		 
		//if(parseDimens()){ 
		    lp.leftMargin = left_margin;
	        lp.topMargin = top_margin;
	        lp.rightMargin =right_margin;