我正在嘗試調整AlertDialog的大小,我之前完成了這個操作,但不記得我是如何做到的。以下是我使用的代碼,但它只是工作。有人能夠指出我做錯了什麼。Android - 無法調整AlertDialog
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
alertDialogBuilder
.setMessage(R.string.checkout_journey_selector_popup_title)
.setPositiveButton(R.string.checkout_journey_selector_popup_paylater_button,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
CheckoutHelper.startReservationJourney(getActivity(),
collectibleItems);
}
})
.setNegativeButton(R.string.checkout_journey_selector_popup_paynow_button,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
CheckoutHelper.startPrepayCollectionJourney(getActivity(),
collectibleItems);
}
}).create().show();
Dialog alert = alertDialogBuilder.create();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(alert.getWindow().getAttributes());
lp.height = 100;
lp.width = 50;
alert.getWindow().setAttributes(lp);
在此先感謝
試試這個'alertDialog.getWindow()的setLayout(600,400);''後alertDialog.show() ;' –
在佈局 – Gayathiri