Skip to content

Instantly share code, notes, and snippets.

@billynyh
Created September 17, 2014 02:01
Show Gist options
  • Save billynyh/d949d233c6f313271182 to your computer and use it in GitHub Desktop.
Save billynyh/d949d233c6f313271182 to your computer and use it in GitHub Desktop.
keep view's padding when changing 9patch background
public void setBackgroundResource(View v, int id) {
int bottom = v.getPaddingBottom();
int top = v.getPaddingTop();
int right = v.getPaddingRight();
int left = v.getPaddingLeft();
v.setBackgroundResource(id);
v.setPadding(left, top, right, bottom);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment