Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When focused EditText inside ListView or RecyclerView, the keyboard showing but scrolling not working

When I touched the EditText inside ListView or RecyclerView the soft keyboard showing. Then i clicked the next button on keyboard and the focus changed to next EditText. After last visible EditText, the focus changing to next EditText but ListView or RecyclerView not scrolling inside and all the screen going under the status bar every keyboard next Button clicked.

The following xml which is using for this screen:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <include
            android:id="@+id/MainToolbar"
            layout="@layout/toolbar" />
        <include
            android:id="@+id/llHeaderItem"
            layout="@layout/TaskShelfShareHeaderItem" />
        <ListView
            android:id="@+id/lwShelfShare"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:stackFromBottom="true"
            android:transcriptMode="normal" />
    </LinearLayout>

Screen cast

like image 507
Samet KAHRAMAN Avatar asked Jul 07 '15 07:07

Samet KAHRAMAN


People also ask

How do I show soft keyboard when EditText is focused?

android:windowSoftInputMode="stateAlwaysVisible" -> in manifest File. edittext. requestFocus(); -> in code. This will open soft keyboard on which edit-text has request focus as activity appears.

How do I scroll up layout when clicking on EditText?

than change layout design. or if it's possible for you than try this android:layout_height="match_parent" to RelativeLayout and give it a fix id also. maybe it's work for you.

What is windowSoftInputMode?

The soft keyboard can be configured for each activity within the AndroidManifest. xml file using the android:windowSoftInputMode attribute to adjust both default visibility and also how the keyboard affects the UI when displayed.


1 Answers

I figured it out this way. Hope it helps.

mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        RecyclerView recyclerView = getRecyclerView();
        if (recyclerView != null) {
            int position = getLayoutPosition();
            RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForLayoutPosition(position + 1);
            if (viewHolder == null) {
                recyclerView.smoothScrollToPosition(position + 1);
                return true;
            }
        }
        return false;
    }
});
like image 56
Ivan Vazhnov Avatar answered Sep 29 '22 22:09

Ivan Vazhnov