Как предотвратить редактирование текста с перекрытиями recyclerView? - PullRequest
0 голосов
/ 08 января 2019

Проблема в том, что когда появляется программная клавиатура, она перекрывает окно реселлера. Но я хочу, чтобы моя мягкая клавиатура просто подталкивала ресайклер вверх, чтобы она была над клавиатурой, как при windowSoftInputMode = "AdjustPan" . Но AdjustPan - это не вариант, потому что мне нужна панель инструментов.
Я уже пытался настроить Adjust, но не повезло.

Макет основной деятельности

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
>

<include
        layout="@layout/toolbar_layout"
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
/>

<androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:id="@+id/recyc"
        app:layout_constraintBottom_toTopOf="@+id/message_edit_text"
        app:layout_constraintTop_toBottomOf="@+id/toolbar_layout"/>


<com.google.android.material.textfield.TextInputEditText
        android:id="@+id/message_edit_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textShortMessage"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"/>


</androidx.constraintlayout.widget.ConstraintLayout>

Расположение элементов адаптера

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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="wrap_content">


<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

Вот мой MainActivity код, есть единственный метод onCreate

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    recyc.layoutManager = LinearLayoutManager(this)
    val adapter = MyAdapter(
        arrayOf("sd","sd2","sd2","sd2","sd2","s2d","s2d","sd",
            "sd2","s2d","s2d","sd5","s8d","67sd","s76d")
    )
    recyc.adapter = adapter
}

Вот мой класс адаптера

class MyAdapter(private val myDataset: Array<String>) :
RecyclerView.Adapter<MyAdapter.MyViewHolder>() {

class MyViewHolder(val view: View) : 
RecyclerView.ViewHolder(view)

override fun onCreateViewHolder(
    parent: ViewGroup,
    viewType: Int
): MyAdapter.MyViewHolder {
    val textView = LayoutInflater.from(parent.context)
        .inflate(R.layout.container, parent, false)
    return MyViewHolder(textView)
}

    override fun onBindViewHolder(holder: MyViewHolder, position: Int) 
      { holder.itemView.textView.text = myDataset[position] }

    override fun getItemCount() = myDataset.size
}
...