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

 

 

你可能感兴趣的:(Android的TextView设置padding无效)