I have trouble to align default material buttons with other elements of the UI. In fact I have looked at the Android source code and the background for the buttons contains insets to be able to draw the shadow and deal with the elevation of the button when clicked:
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="@dimen/abc_button_inset_horizontal_material"
android:insetTop="@dimen/abc_button_inset_vertical_material"
android:insetRight="@dimen/abc_button_inset_horizontal_material"
android:insetBottom="@dimen/abc_button_inset_vertical_material">
<shape android:shape="rectangle">
<corners android:radius="@dimen/abc_control_corner_material" />
<solid android:color="@android:color/white" />
<padding android:left="@dimen/abc_button_padding_horizontal_material"
android:top="@dimen/abc_button_padding_vertical_material"
android:right="@dimen/abc_button_padding_horizontal_material"
android:bottom="@dimen/abc_button_padding_vertical_material" />
</shape>
</inset>
So, I have the very basic layout below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
>
<View
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#123456"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test button alignment"
/>
<View
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#123456"
/>
</LinearLayout>
And as you can see, the left edge of the button is not aligned with the left edges of the other views.
So my question is, is there a way to get rid of these insets without loosing the shadow/elevation handled out of the box by default Android buttons to have the UI well aligned?
Thanks!