Search code examples
androidandroid-actionbarandroid-support-libraryandroid-actionmodeandroiddesignsupport

Action mode partly hidden by status bar


I'm trying to use the new material design AlertDialogs in the Support Library.

I have a case in which I have an EditText inside an AlertDialog. In that EditText, if I long-press to select the text, the Action Bar appears on the top of the screen, containing the select all, cut and copy buttons.

The problem I have is that the action bar is partly hidden by the Android status bar, making me unable to select the cut or copy buttons.

How do I make the action bar not be partly hidden and available for use?

I'm able to reproduce this problem by creating a new project in Android Studio, and writing this code into the onCreate method:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    EditText et = new EditText(this);
    et.setText("Hello world");

    AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setTitle("Test");
    b.setPositiveButton("OK", null);
    b.setView(et);
    b.create().show();
}

Here is the result I get in the emulator:

Action bar partly hidden


Solution

  • It looks like this is a bug in appcompat-v7 that is resolved in the Android M version of the library.

    Here is the link to the bug: https://code.google.com/p/android/issues/detail?id=170105