This requirement is generally not used, but it is very depressing to meet. This should be considered a bug in the SDK, the solution is to set up before recording his margin,
Then set back in.
Specific methods
/** * settings do not change padding background * Because Android has set background, padding invalid problem * * @param view * @param resId * @autor Wujiajun * /public static void setbackgroundresourcewithpadding (view view, int resId) { int bottom = View.getpaddingbottom (); int top = View.getpaddingtop (); int right = View.getpaddingright (); int left = View.getpaddingleft (); View.setbackgroundresource (resId); View.setpadding (left, top, right, bottom); }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android View Change background resource, padding disappearing issue