我有一个层级结构如下的ConstraintLayout
:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="parent"/>
<RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="Button"
app:layout_constraintTop_toBottomOf="EditText"/>
<Button
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
</ConstraintLayout>
当
EditText
获得焦点时,键盘将弹出并推动Button
(因此也推动了RecyclerView
)。我不希望发生这种情况,让键盘自由地弹出而不推动任何视图。我尝试了很多
android:windowSoftInputMode
组合(以下是示例),但都没有成功。还有ScrollView
的“hack”,但也没有成功。<activity
android:name=".Activity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"/>
我该如何实现这个呢?
附言:我能想到的唯一解决方案就是在键盘弹出时隐藏按钮
。