0

私はAlertDialogにカスタムスタイルを使用していますが、全画面表示にしています。ここでカスタムテーマを使用してAlertDialogが全画面表示されないようにするにはどうすればよいですか?

は自分のスタイル

<style name="MyDialog" parent="AlertDialog.AppCompat"> 
    <item name="android:background">@color/material_dark</item> 
    <item name="android:layout_height">100dp</item> 
    <item name="android:textColor">@color/accent</item> 
    <item name="android:textColorPrimary">@color/material_white</item> 
</style> 

そして、私のAlertDialog秒の一つである...私の周りで検索しましたが、私はそれがフルスクリーンにするためにを望む人を見つけるように見えることができます。

AlertDialog alertDialog = new AlertDialog.Builder(this.getContext(), R.style.MyDialog) 
      .setIcon(android.R.drawable.ic_dialog_alert) 
      .setTitle(this.getContext().getResources().getString(R.string.reset) + "?") 
      .setMessage(this.getContext().getResources().getString(R.string.AreYouSure)) 
      .setPositiveButton(getString(R.string.yes), (dialog, which) -> { 
       reset(); 
      }) 
      .setNegativeButton(getString(R.string.notReally), (dialog, which) ->{ 
       //Do nothing 
      }) 
      .show(); 

これはそのようです。なぜそれが画面全体を占めるのか分かりません。カスタムカラーの場合はAlertDialogのように表示されます。

enter image description here

+0

wrap_content' 'でreset.xmlのあなたの親のレイアウトの確認高さを作ります。 –

+1

trueを自分のスタイルに追加してください –

+0

@ deepakjohn141これはトリックでした。 –

答えて

1
add <item name="android:windowIsFloating">true</item> to MyDialog style 
関連する問題