Android TextView drawable, change padding between drawable and text? Android TextView drawable, change padding between drawable and text? android android

Android TextView drawable, change padding between drawable and text?


You'll need to combine drawablePadding and padding to get the desired result.


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.


  <Button            android:id="@+id/otherapps"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:background="@drawable/btn_background"            android:text="@string/other_apps"            android:layout_weight="1"            android:fontFamily="cursive"            android:layout_marginBottom="10dp"            android:drawableLeft="@drawable/ic_more"            android:paddingLeft="8dp" //for drawable padding to the left            android:textColor="@android:color/holo_red_light" />`enter code here`