Android Dialog/AlertDialog Default Padding of Custom View

July 24, 2018

Custom view layout with EditText for AlertDialog.

  • Use ?dialogPreferredPadding for left and right padding of dialog’s custom view. It will align the content with title’s padding.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="?dialogPreferredPadding"
    android:paddingRight="?dialogPreferredPadding"
    >

    <EditText
        android:id="@+id/editText"
        android:hint="Hello"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</FrameLayout>
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.