Where'd padding go, when setting background Drawable?

后端 未结 16 1347
攒了一身酷
攒了一身酷 2020-12-03 00:41

I have this issue on my EditText and Button views, where I have a nice padding for them to space away from the text, but when I change the backgrou

16条回答
  •  情书的邮戳
    2020-12-03 00:52

    You can give some padding by using 9-patch images and defining the content area in the drawable. Check this

    You can also set the padding in your layout from xml or programatically

    xml padding tags

    android:padding
    android:paddingLeft
    android:paddingRight
    android:paddingTop
    android:paddingBottom
    

    You can try setting the padding manually from the code after you call the setBackgroundDrawable by calling setPadding on your EditText or Button Views

提交回复
热议问题