Мягкая клавиатура Android накладывает текст редактирования в recyclerview на нижнем листе

У меня есть несколько EditText в RecyclerView, которые находятся внутри BottomSheetDialog. У меня сейчас проблема в том, что когда на экране отображается BottomSheetDialog, я нажимаю, например, на 7-й EditText в RecyclerView. Появляется программная клавиатура и перекрывает EditText, поэтому я не вижу, что печатаю. но если я перетащу BottomSheetDialog немного вверх, EditText не будет закрыто программной клавиатурой, даже если я нажму на последний EditText на экране. Размер RecyclerView определенно изменяется в этом случае, но не изменяется, если я не перетащил BottonSheetDialog немного вверх. есть идеи, почему? и как я могу это исправить?

вот как это выглядит. введите здесь описание изображения

Main.java

class VH extends RecyclerView.ViewHolder {
    public VH(View itemView) {
        super(itemView);
    }
}

private void test() {
    BSTest bsTest = new BSTest(this);
    bsTest.setContentView(R.layout.bottomsheet_test);
    RecyclerView rv = (RecyclerView) bsTest.findViewById(R.id.recyclerView);
    rv.setLayoutManager(new LinearLayoutManager(this));
    rv.setAdapter(new RecyclerView.Adapter() {
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return new VH(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_edittext, parent, false));
        }

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        }

        @Override
        public int getItemCount() {
            return 20;
        }
    });
    bsTest.show();
}

BSTest.java

public class BSTest extends BottomSheetDialog {
    public BSTest(@NonNull Context context) {
        super(context);
    }

    private BSTest(@NonNull Context context, @StyleRes int theme) {
        super(context, theme);
    }

    private BSTest(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }
}

нижний лист_test.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="1"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="2"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="3"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

item_edittext.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="1"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="2"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="3"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

person user1865027    schedule 17.11.2016    source источник
comment
покажи скриншот   -  person Marcin Orlowski    schedule 17.11.2016
comment
я добавил короткое видео   -  person user1865027    schedule 18.11.2016
comment
@user1865027 user1865027 вы узнали проблему/решение проблемы?   -  person Nitin Misra    schedule 11.02.2017
comment
@NitinMisra попробуйте с этим stackoverflow. com/questions/39288879/ (в настоящее время тестируется)   -  person LOG_TAG    schedule 17.02.2017
comment
@NitinMisra попробуйте это для полноэкранного режима «установить заголовок и подзаголовок в макете сворачивающейся панели инструментов android»> stackoverflow.com/questions/33361569/   -  person LOG_TAG    schedule 17.02.2017


Ответы (2)


Использование этого KeyboardUtil в качестве нового решения!

Используйте это в onCreateDialog в BottomSheetFragment

KeyboardUtil(getActivity(), view);

or

Для использования фрагмента

new KeyboardUtil(this, findViewById(R.id.fragment_container));

с помощью этого класса Util

https://github.com/mikepenz/MaterialDrawer/blob/aa9136fb4f5b3a80460fe5f47213985026d20c88/library/src/main/java/com/mikepenz/materialdrawer/util/KeyboardUtil.java

1 кредит

person LOG_TAG    schedule 17.02.2017

Похоже, что редактирование вашего манифеста и добавление тега android:windowSoftInputMode="adjustResize" к <activity> этого действия должно решить вашу проблему.

Документы: https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

person Marcin Orlowski    schedule 17.11.2016
comment
неее... не работает. и если adjustResize была причиной, почему размер первого ввода не изменился, а 2-й ввод изменился. - person user1865027; 18.11.2016