I am trying to add a red dot below the text of a button, however the default padding is way too large. too large padding
However, when I remove the background drawable, the padding becomes more reasonable. reasonable padding
Here are the XMLs:
Dot drawable:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid
android:color="#fff"/>
<size
android:height="5dp"
android:width="5dp"/>
</shape>
</item>
</selector>
Background drawable:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#000"/>
</shape>
</item>
</selector>
Button:
<Button
android:id="@+id/button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/background"
android:drawableBottom="@drawable/dot"
android:drawableTint="#FF0000"
android:insetTop="0dp"
android:insetBottom="0dp"
android:text="-"
app:cornerRadius="0px" />
Is there any way to keep reduce the padding further while keeping the background set?
You can set a negative padding in your Button. That will fix your problem.
Or you can make a custom button using a linearLayout. In that linearLayout, you can place your views as you want and then treat the linearLayout as a button.