我創建通過下面的代碼定製alertdialog:安卓:自定義AlertDialog
AlertDialog.Builder builder;
AlertDialog alertDialog;
LayoutInflater inflater = (LayoutInflater)ActivityName.this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_layout,(ViewGroup)findViewById(R.id.layout_root));
builder = new AlertDialog.Builder(getParent());
builder.setView(layout);
alertDialog = builder.create();
alertDialog.show();
問題是彈出與具有所有權自己空隙默認對話框背景包圍(如標題是沒有設置)。我如何刪除這個。我曾試圖通過ContextThemeWrapper
像 builder = new AlertDialog.Builder(new ContextThemeWrapper(getParent(), R.style.CustomDialogTheme));
但它不工作。我怎麼做?!!!提前致謝。下面 自定義XML樣式給出:
<style name="CustomDialogTheme" parent="android:style/Theme.Dialog.Alert">
<item name="android:windowIsFloating">false</item>
<item name="android:windowNoTitle">true</item>
</style>
那麼不顯示標題是要迷惑用戶,你應該能顯示在對話框標題,因爲它的預期標準。 – JoxTraex
我在佈局中附加了標題(例如,「Set As ...」,如你所見) – IronBlossom