Vivian Ambrose
Vivian Ambrose

Reputation: 3

Set padding for textview works only after setting background resource - Android

Setting the background resource to a drawable xml for a textview after setting its padding doesn't pad the textview, but vice versa works. How ?

Example

works

   textView.setBackgroundResource(borderColor);
   textView.setPadding(10, 0, 10, 0);

doesn't work

   textView.setPadding(10, 0, 10, 0);
   textView.setBackgroundResource(borderColor);

Upvotes: 0

Views: 1388

Answers (1)

alvaro torrico
alvaro torrico

Reputation: 765

When you change the background, the padding is reset. This is the default behaviour. You can find more about this: here and here

Upvotes: 5

Related Questions