Skip to content

Instantly share code, notes, and snippets.

@mahdimortazavi
Last active June 18, 2016 07:43
Show Gist options
  • Save mahdimortazavi/5956ca3ea0be2cf5ddb6548d5aabd0ac to your computer and use it in GitHub Desktop.
Save mahdimortazavi/5956ca3ea0be2cf5ddb6548d5aabd0ac to your computer and use it in GitHub Desktop.
margin and background color for Button
Button button=(Button)findViewById(R.id.button);
Button button2=(Button)findViewById(R.id.button2);
button.setBackgroundColor(getResources().getColor(R.color.grey_100));
button2.setBackgroundColor(getResources().getColor(R.color.grey_100));
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) button.getLayoutParams();
params.leftMargin=7;
params.rightMargin=7;
ViewGroup.MarginLayoutParams params2 = (ViewGroup.MarginLayoutParams) button2.getLayoutParams();
params2.leftMargin=7;
params2.rightMargin=7;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment