android的
checkLine.setBackgroundResource(R.drawable.bg_rectangle);
設置背景後出現padding失效的問題
方式一 先獲取checkLine的padding值 在setBackgroundResource()之後增加 setPadding 代碼
int left = checkLine.getPaddingLeft();
int right = checkLine.getPaddingRight();
int top = checkLine.getPaddingTop();
int bottom = checkLine.getPaddingBottom();
checkLine.setBackgroundResource(R.drawable.bg_rectangle);
checkLine.setPadding(int left, int top, int right, int bottom)
方拾二 : 在子View中加margin控制內容和邊界 的間距,親測可行,記錄下