Skip to content

Instantly share code, notes, and snippets.

@valentincognito
Created June 7, 2018 07:56
Show Gist options
  • Save valentincognito/0ef8e14d7b41acd0197343b48fc774bb to your computer and use it in GitHub Desktop.
Save valentincognito/0ef8e14d7b41acd0197343b48fc774bb to your computer and use it in GitHub Desktop.
Create and add a new imageView in a relativeLayout with parameters
RelativeLayout rl = findViewById(R.id.spenViewLayout);
ImageView duplicate = new ImageView(getApplicationContext());
duplicate.setImageDrawable(getDrawable(R.drawable.love));
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(300, 300);
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
rl.addView(duplicate, params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment