I'd like to place a drawable into a dialogs title bar. I tried the following:
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.some_icon);
dialog.setTitle(R.string.my_dialog_title);
dialog.setContentView(R.layout.my_dialog_layout);
...
The icon doesn't show up but the title moves a little to the right. It seems the dialog reserves space for the drawable but doesn't draw it. I tried several different icons (also from the android resources) but non of them worked.
AlertDialog. A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout. DatePickerDialog or TimePickerDialog. A dialog with a pre-defined UI that allows the user to select a date or time.
Call setFeatureDrawableResource()
after show()
.
No idea why this works. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With