Skip to content

Instantly share code, notes, and snippets.

@kitek
Created June 21, 2013 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitek/5831361 to your computer and use it in GitHub Desktop.
Save kitek/5831361 to your computer and use it in GitHub Desktop.
Replace 9patch background with padding
NinePatchDrawable bg = (NinePatchDrawable) getResources().getDrawable(R.drawable.button_new_light);
int pL = btnLike.getPaddingLeft();
int pR = btnLike.getPaddingRight();
int pT = btnLike.getPaddingTop();
int pB = btnLike.getPaddingBottom();
if(Build.VERSION.SDK_INT >= 16) {
btnLike.setBackground(bg);
} else {
btnLike.setBackgroundDrawable(bg);
}
btnLike.setPadding(pL, pT, pR, pB);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment