Code example for RelativeLayout

Methods: addView

0
 
        // Have the system blur any windows behind this one. 
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
         
        RelativeLayout container = new RelativeLayout(this);
         
        ImageButton button = new ImageButton(this);
        button.setImageResource(getIntent().getIntExtra("moodimg", 0));
        button.setOnClickListener(this);
         
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);
         
        container.addView(button, lp);
         
        setContentView(container);
    } 
 
    public void onClick(View v) {
Stop searching for code, let great code find you!  Add Codota to your java IDE