Android TextView drawable, change padding between drawable and text?

后端 未结 4 674
囚心锁ツ
囚心锁ツ 2020-12-30 18:14

I am creating a TextView with a drawable underneath, in a GridLayout.

I want to bring the drawable to the middle of the TextView

4条回答
  •  甜味超标
    2020-12-30 18:59

    In XML:

    android:drawablePadding = paddingValue
    

    or

    Programmatically:

    TextView txt;
    
    txt.setCompoundDrawablePadding(paddingValue)
    

    android:drawablePadding is the easiest way to give padding to the drawable icon but you can not give specific one side padding like paddingRight or paddingLeft of the drawable icon. This gives padding to either side of the drawable.

提交回复
热议问题