When we use setBackgroundResource(), it automatically reset some property in our XML. The most common things that happen is padding. We can set padding that changed by setBackgroundResource by :
1 | yourView.setPadding(<left>, <top>, <right>, <bottom>); |
1 2 | search.setBackgroundResource(R.drawable.search_noborder); search.setPadding(10, 0, 40, 0); |