[Android疑难杂症]动态改变Background后Padding无效的问题
一、折中办法 1.1 方法一 intbottom=theView.getPaddingBottom(); inttop=theView.getPaddingTop(); intright=theView.getPaddingRight(); intleft=theView.getPaddingLeft(); theView.setBackgroundResource(R.drawable.entry_bg_with_image); theView.setPadding(left,top,right,bottom); 1.2 方法二 intpad=resources.getDimensionPixelSize(R.dimen.linear_layout_padding); theView.setBackgroundResource(R.drawable.entry_bg_with_image); theView.setPadding(pad,pad,pad,pad); 代码说明: 实际上就是在setBackgroundResource之后重新设置一下padding。 二、原帖...