-5

I have a custom dialog, which xml code is below, but when dialog opens the view is very small, how to customize the size of it

<LinearLayout
    android:orientation="vertical"
    android:background="#ffffff"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <Spinner
        android:id="@+id/name_list"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </Spinner>
    <Button
        android:id="@+id/name_search"
        android:text="Search"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:background="#ffffff"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
Karthick Ramanathan
  • 642
  • 3
  • 9
  • 20

1 Answers1

3

Try this

custom dialog set height and width programatically using Window

Window window = customDialog.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
window.setGravity(Gravity.CENTER);
customDialog.show();
Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31