'Android. PaddingLeft or PaddingRight for button has no effect

It's kind of duplicate question. But since no solution worked for me I would try again.

I have just a simple button in my layout.

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_weight="1"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:paddingHorizontal="xyz"
        android:text="My button"/>

</LinearLayout>

And I want to add some horizontal padding for text within it.

However it has no effect.

Maybe you have an idea, what could be the reason for this issue?



Solution 1:[1]

Try using android:paddingHorizontal="72dp" if you want to give padding on both sides. Alternatively if you want to give padding on just a single side you can use android:paddingEnd="32dp" or android:paddingStart="32dp"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jinesh Doshi