Android的TextView设置padding无效

I finally found the problem I have to set the background first before setting the padding. Setting the padding then setting the background doesn't work

// does not work
tv.setPadding(20, 20, 20, 20);
tv.setBackgroundResource(R.drawable.border);


// works
tv.setBackgroundResource(R.drawable.border);
tv.setPadding(20, 20, 20, 20);

原文地址:https://stackoverflow.com/questions/18327498/setting-padding-for-textview-not-working

 
原文地址:https://www.cnblogs.com/albert1017/p/8881247.html