Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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