0

I am developing an application in android, where i would like to shrink the size of the default alertdialog. How can i set the size of an AlertDialog in Android?

Udit Shah
  • 241
  • 2
  • 14

1 Answers1

0

You can set your own XML layout for a dialog (example below called species_prompt), then call

speciesDialog.setContentView(R.layout.species_prompt);
    TextView text = (TextView) speciesDialog
            .findViewById(R.id.specieshelptext);

in your dialog method, calling each view appropriately (I only provide one example above...)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_gravity="center_horizontal">

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout android:orientation="vertical"
        android:layout_width="wrap_content" android:layout_height="wrap_content">

        <TextView android:id="@+id/specieshelptext" android:textColor="#FFF"
            android:paddingLeft="5dip" android:paddingRight="5dip"
            android:layout_width="wrap_content" android:layout_height="wrap_content" />
        <Button android:id="@+id/specieshelpbutton"
            android:layout_gravity="center_horizontal" android:layout_below="@id/ScrollView01"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="1.0" android:layout_centerHorizontal="true"
            android:text="Grab species now..." />
        <Button android:id="@+id/speciesdismissButton" android:text="Cancel"
            android:layout_gravity="center_horizontal" android:layout_height="wrap_content"
            android:layout_width="wrap_content" />
    </LinearLayout>
</ScrollView>

iaindownie
  • 1,046
  • 12
  • 28