在对话框中调整自定义布局的高度

时间:2015-07-14 12:01:01

标签: android alertdialog android-alertdialog

我有一个自定义布局的对话框,一切正常,除了底部有一个空的大空间,我无法删除。

任何建议我如何删除那个空白区域。

这是我的代码:

UPDATE `table`
SET parameter_id=
  (SELECT *
   FROM
     (SELECT MIN(t1.parameter_id)+1
      FROM `table` AS t1
      WHERE NOT EXISTS
          (SELECT *
           FROM `table` AS t2
           WHERE t2.parameter_id = t1.parameter_id+1)) AS t4)
WHERE parameter_id IS NULL LIMIT 1

我的XML布局:

public Dialog onCreateDialog() {

    final AlertDialog.Builder builder = new AlertDialog.Builder(
            this);
    // Get the layout inflater
    LayoutInflater inflater = getLayoutInflater();

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout

    builder.setView(inflater.inflate(R.layout.dialogue_cover_staying, null))

    // Add action buttons
           .setPositiveButton("Done", new DialogInterface.OnClickListener() { 
               @Override
               public void onClick(DialogInterface dialog, int id) {
                   //action
               }
           })
           .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                   finish();
               }
           });      

   return builder.show();  
}

Custom AlertDialog box

1 个答案:

答案 0 :(得分:0)

从" wrap_content"更改您的布局宽度和高度到" 100dp"例如..喜欢这个..

<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="100dp"
     android:layout_height="200dp"
     android:background="@drawable/back1"
     android:orientation="vertical" >

此外,您可以设置minWidth和minHeight ..

 android:minWidth="300dp" 
 android:minHeight="400dp"