13
我试图用TextInputLayout创建一个BottomSheetDialogFragment。我将此BottomSheet设置为adjustResize以防止键盘覆盖TextInputLayout。事情是,我得到不同的Android版本不同的行为。BottomSheetDialogFragment中的ADJUST_RESIZE的不同行为
这是布局:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="@android:color/darker_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint" />
</android.support.design.widget.TextInputLayout>
此所述BottomSheetDialogFragment:
public class TestFragment extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
return inflater.inflate(R.layout.fragment_test, container, true);
}
}
这是所期望的结果:
这是我得到的一些版本的结果:
我得到了想要的结果有:
- 银河S6采用Android 7.0
- 仿真器< = Android 5.1
而且没有理想的结果有:
- 的Nexus 5采用Android 7.1.2(LineageOS 14.1)
- 仿真器=>在Android 6.0
有谁知道为什么发生这种情况或如何解决它?
在此先感谢!
干杯。
我试过,但我得到了相同的结果。你能粘贴你使用的xml吗?谢谢 – Buntupana
@Buntupana更新了答案。请尝试解决方案并让我知道结果。:) –
对于延误感到抱歉,我在国外。我复制并粘贴了你的代码,但仍然无法使用。我试过用Android O – Buntupana