Ad
AlertDialog Is Showing Fullscreen For Some Reason
I build and show standart simple AlertDialog from pressing button in navigation drawer, with context of Activity, for unknown reason it shows fullscreen, but I need standart dialog in center.
Here is my code (The same code works as expected in other activities of my app):
new AlertDialog.Builder(mainActivity)
.setTitle(mainActivity.getString(R.string.attention))
.setPositiveButton(mainActivity.getString(R.string.exit), (dialog, which) -> {
dialog.dismiss();
mainActivity.finish();
})
.setNegativeButton(mainActivity.getString(R.string.cancel), (dialog, which) -> {
dialog.dismiss();
})
.setMessage(mainActivity.getString(R.string.warnLogout))
.create()
.show();
Ad
Answer
The problem was in wrong import: I have migrated recently project to AndroidX, and when I wrote AlertDialog logic, mistakenly chose legacy import. It appears that no errors and no warnings been shown, and buttons worked as expected, but it appeared as wrong Fullscreen layout dialog in my case:
WRONG:
import android.app.AlertDialog;
RIGHT:
import androidx.appcompat.app.AlertDialog;
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad