AppCompatActivityの onCreate 関数でAlertDialogを表示したいのですが、何らかの理由で周囲にマージンがありません。画像を参照してください。
これが私のコードです:
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//These are just some setters in the company code
MyApplication.setActivity(this);
setTheme(R.style.AppTheme);
setContentView(R.layout.activity_splash_screen);
Intent intent = getIntent();
String action = intent.getAction();
if(action != null && action.compareTo(Intent.ACTION_VIEW) == 0){
mHasContent = true;
mContentUri = intent.getData();
}else{
mHasContent = false;
}
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
initViews();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("title");
builder.setMessage("message");
builder.create().show();
}
何が問題の原因なのかわかりません。コード内の他の場所でダイアログが正しく表示されています。
(onResumeに入れようとしましたが、うまくいきません。アクティビティが作成されたときにのみ表示したいので、onCreateを使用しようとしています。)
カスタム AppTheme が問題を引き起こす可能性はありますか? そう思う場合は、styles.xml の関連部分を添付します。
...
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
...
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="toolbarStyle">@style/Toolbar</item>
<item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
...
</style>
...
新しいプロジェクトを作成し、上位のすべてのコード (styles.xml およびその他すべて) をその中に入れようとしましたが、バグを再現できません。他に何が問題を引き起こす可能性がありますか?
どこに問題がありますか?誰でも助けることができますか?
オーバーライドされた onCreate() 関数を持つアプリケーション クラスもあり、それらの関数呼び出しも削除しようとしましたが、何も変わりませんでした。この動作に影響を与える可能性のあるアンドロイドの他の場所はありますか? 会社のアプリなので、コード全体がわかりません。おそらく、他のオーバーライドされたメソッドか何かですか?
