Search code examples
androidandroid-softkeyboardcontextual-action-bar

Holding keyboard on top, contextual menu hide when i mark text


I currently have the problem, when i mark the text, and the keyboard is hidden, the contextual menu is showing and going up, to make a "area" for the keyboard. It looks like this, you can see a bit from the contextual menu on the top below at status bar:

enter image description here

My layout to this activity:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<LinearLayout
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="wrap_content">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        />

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="10dp"
        android:padding="10dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            >

            <EditText
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:nextFocusForward="@id/text"
                android:imeOptions="actionNext"
                android:singleLine="true"
                android:ems="16"
                android:hint="@string/title"
                android:textColor="#212121"
                android:textColorHint="#757575"
                android:background="@null"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                android:scrollbars="horizontal"

                android:transitionName="title"
                />

            <EditText
                android:id="@+id/text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/text"
                android:textColor="#212121"
                android:textColorHint="#757575"
                android:background="@null"
                android:layout_marginLeft="2dp"
                />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="15dp"
                android:layout_marginBottom="15dp"
                android:elevation="0dp"
                android:background="@color/grey"
                />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                >

                <ImageButton
                    android:id="@+id/fav"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_star_black_24dp"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:padding="5dp"
                    android:background="?android:attr/selectableItemBackground"
                    android:tint="#9E9E9E"
                    />


            </RelativeLayout>


        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>
</LinearLayout>


<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:gravity="top"
    android:id="@+id/snackbar">
</android.support.design.widget.CoordinatorLayout>

Any suggestions?


Solution

  • What I would suggest is to create a ScrollView and to put your text and other elements in it. That will leave your toolbar or actionbar alone.