Android copy / paste context menu has ghost background when used in dialog
Asked Answered
D

1

0

I have a simple dialog which contains a note field, and when i long press on an item, this happens (I attach different status, to better understand the problem)

Menu when selecting a text

Menu when selecting a text and after tapping on the 3 dots

Menu when selecting a blank space

Now, here's what I already tried:

  • Custom layout changes. What i do is using the normal MaterialAlertDialogBuilder with the setview method. The view itself is just a text field, but I also tried to encapsulate it in a frame layout, or to put a simple textview with selectable text. No changes. Here's the kotlin part

         // Native dialog
         MaterialAlertDialogBuilder(act)
             .setView(dialogNotesBinding.root)
             .setTitle(notesTitle)
             .setIcon(R.drawable.ic_note_24dp)
             .setPositiveButton(resources.getString(android.R.string.ok)) { dialog, _ ->
                 ...
             }
             .setNegativeButton(resources.getString(android.R.string.cancel)) { dialog, _ ->
                 dialog.dismiss()
             }
             .show()
    

And here's the custom layout:

  <?xml version="1.0" encoding="utf-8"?>
  <com.google.android.material.textfield.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/favoritesNotesLayout"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ... >

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/favoritesNotes"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ... />

</com.google.android.material.textfield.TextInputLayout>
  • Change Material components version: I tried 1.12.0 and 1.13.0 alpha, no changes

I'm out of ideas.

Davey answered 13/7 at 15:20 Comment(2)
What is the expected output? The pictures look as expectedHautboy
There's a huge box behind the context menu. I figured it out though, I'll reply to myself :)Davey
D
1

Long story short: I have a style for the dialogs, similar to the one used in the answer to this question But, setting the attribute android:background for the dialogs causes this bug on the context menu. The solution is theming the preference dialogs using android:dialogPreferenceStyle instead of materialAlertDialogTheme the solution works in the same way, but has less side effects.

Davey answered 15/7 at 16:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.