Where'd padding go, when setting background Drawable?
android
Solution
What I found was adding a 9 patch as a background resource reset the padding - although interestingly if I added a color, or non-9 patch image, it didn't. The solution was to save the padding values before the background gets added, then set them again afterwards.
private EditText value = (EditText) findViewById(R.id.value);
int pL = value.getPaddingLeft();
int pT = value.getPaddingTop();
int pR = value.getPaddingRight();
int pB = value.getPaddingBottom();
value.setBackgroundResource(R.drawable.bkg);
value.setPadding(pL, pT, pR, pB);
Problem
I have this issue on my `EditText` and `Button` views, where I have a nice padding for them to space away from the text, but when I change the background with `setBackgroundDrawable` or `setBackgroundResource` that padding is lost forever.