如何为FragmentDialog指定最小宽度?

时间:2013-07-15 08:55:08

标签: android android-dialogfragment

如何为FragmentDialog指定最小宽度?

class TestImage extends DialogFragment{ 
    public Dialog onCreateDialog(Bundle savedInstanceState) { 
        AlertDialog.Builder adb = new AlertDialog.Builder(getActivity()); 
        TableLayout table = new TableLayout(getActivity()); 
        TableRow row = new TableRow(getActivity()); 
        row.addView(new ImageButton(getActivity())); 
        row.addView(new ImageButton(getActivity())); 
        table.addView(row); 
        adb.setView(table); 
        return adb.create(); 
    } 
}
在这个位置提出的答案没有帮助。 How to set DialogFragment's width and height?

1 个答案:

答案 0 :(得分:0)

在XML中设置android:minWidth="300dp"

检查http://developer.android.com/guide/components/fragments.html#Adding的放置位置。