0

There are posts related to elevation for views for pre-lollipop devices. I applied techniques that could be applied to the dialog but I still can not have elevation/shadow to my dialog.

I tried this in the style but it did not work.

<item name="android:background">@android:drawable/dialog_holo_light_frame</item>  

ViewCompat.setElevation() and View.setOutLineProvider() methods are available from Lollipop. So can not use them.

I am not able to add the screeshots here for unknown reason. But the dialog is flat on KK and is elevated and look nice on Lollipop.

This is how I created dialog:

AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.AlertDialogStyle));
Dialog dialog = builder.create();

And AlertDialogStyle is just this:

<style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
</style>

Can you help me with any clue on how can I add elevation to dialog on pre-lollipop or pre-21 devices ?

cgr
  • 4,578
  • 2
  • 28
  • 52

1 Answers1

0

Well, it is not an answer to the question but it is an alternative I had to do for things to work in app.

So, I've used PopupMenu instead of dialog and changed my app theme from

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">

to

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
cgr
  • 4,578
  • 2
  • 28
  • 52