Android 单击ViewPager的编辑文本时,软键盘保持关闭
我有一个片段,它包含一个由2个片段组成的ViewPager2。 在第二个子片段中,我有一个recyclerview,其中viewholder包含TextView和EditText 在emulator中,当我在EditView中单击时,软键盘会一直关闭 在real device(Sony xperia XA)中,软键盘不会关闭,但无论我是否在另一个编辑文本中单击,它始终关注第一个编辑文本 我曾经尝试过使用android:windowSoftInputMode=“adjustPan”和android:windowSoftInputMode=“adjustResize”,但并没有解决这个问题 我在LinearLayout外部使用数据绑定和约束Android 单击ViewPager的编辑文本时,软键盘保持关闭,android,android-recyclerview,android-edittext,android-softkeyboard,Android,Android Recyclerview,Android Edittext,Android Softkeyboard,我有一个片段,它包含一个由2个片段组成的ViewPager2。 在第二个子片段中,我有一个recyclerview,其中viewholder包含TextView和EditText 在emulator中,当我在EditView中单击时,软键盘会一直关闭 在real device(Sony xperia XA)中,软键盘不会关闭,但无论我是否在另一个编辑文本中单击,它始终关注第一个编辑文本 我曾经尝试过使用android:windowSoftInputMode=“adjustPan”和android
<LinearLayout
android:id="@+id/wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context="vn.com.ntn.obee.screens.fragments.exercise.InputQuestionFragment">
<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_medium"
android:layout_marginEnd="@dimen/margin_medium"
android:layout_marginBottom="@dimen/margin_medium"
android:paddingTop="@dimen/margin"
android:paddingBottom="@dimen/margin_medium"
app:cardCornerRadius="20dp"
app:cardElevation="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layoutQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/question_drawable"
android:orientation="vertical"
android:paddingTop="@dimen/margin"
android:paddingBottom="@dimen/margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<vn.com.ntn.obee.screens.views.SelectableTextView
android:id="@+id/tvQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.6"
android:maxHeight="200dp"
android:paddingStart="@dimen/margin_medium"
android:paddingEnd="@dimen/margin_medium"
android:paddingTop="@dimen/margin"
android:paddingBottom="@dimen/margin_medium"
android:scrollbars="vertical"
android:fontFamily="@font/proxima_nova_bold"
android:textColor="@color/white"
android:textSize="@dimen/text_size_normal"
app:htmlText="@{answer.content ?? answerResult.contentExtend}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/etAnswer"
android:layout_width="match_parent"
android:layout_height="@dimen/size_icon_x5"
android:hint="@string/enter_your_answer_here"
android:paddingStart="@dimen/margin_medium"
android:paddingEnd="@dimen/margin_medium"
android:paddingBottom="2dp"
android:layout_marginStart="@dimen/margin_medium"
android:layout_marginEnd="@dimen/margin_medium"
android:layout_marginBottom="@dimen/margin_small"
android:background="@drawable/bg_input_question_edittext"
android:fontFamily="@font/proxima_nova_bold"
android:textColor="@color/pink"
android:textColorHint="#FFC9C9"
android:textSize="@dimen/text_size_medium"
android:singleLine="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvQuestion"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="1"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
问题是我使用了太多的约束布局。 我将约束布局用于:
- ViewPager的子片段
- 回收器视图的项目
注意:使用NestedScrollView包装我的回收器视图可以解决我的问题,但它阻止我滚动回收器视图您可以共享项目的xml布局吗?@NehaK我已将项目的xml布局更新到问题中,您可以为我发布“vn.com.ntn.obee.screens.views.SelectableTextView”的代码吗,但还没有尝试使用SelectableTextView,问题可能就在这里only@NehaK我已尝试删除SelectableTextView,但这不是问题所在
2020-10-12 00:20:43.527 3051-3051/? I/KeyboardViewUtil: KeyboardViewUtil.getKeyboardHeightRatio():128 systemKeyboardHeightRatio:1.000000; userKeyboardHeightRatio:1.000000.
2020-10-12 00:20:43.528 3051-3051/? I/AndroidIME: AbstractIme.onActivate():83 LatinIme.onActivate() : EditorInfo = Package = com.nghianguyen.obee_android.debug : Type = Text : Learning = Enable : Suggestion = Show : AutoCorrection = Enable : Microphone = Show : NoPersonalizedLearning = Disable, IncognitoMode = false
2020-10-12 00:20:43.529 3051-3051/? I/Delight5Facilitator: Delight5Facilitator.initializeForIme():572 initializeForIme() : Locale = [en_US], layout = qwerty
2020-10-12 00:20:43.529 3051-3051/? I/VoiceInputManagerWrapper: VoiceInputManagerWrapper.cancelShutdown():54 cancelShutdown()
2020-10-12 00:20:43.529 3051-3051/? I/VoiceInputManagerWrapper: VoiceInputManagerWrapper.syncLanguagePacks():66 syncLanguagePacks()
2020-10-12 00:20:43.557 3051-6376/? I/SpeechFactory: SpeechRecognitionFactory.maybeScheduleAutoPackDownloadForFallback():155 maybeScheduleAutoPackDownloadForFallback()
2020-10-12 00:20:43.569 1845-1845/? E/servicemanager: Could not find android.hardware.power.IPower/default in the VINTF manifest.
2020-10-12 00:20:43.596 3051-3051/? I/KeyboardWrapper: KeyboardWrapper.consumeEvent():264 Skip consuming an event as current keyboard is deactivated (state=0, keyboard existence=true)
2020-10-12 00:20:43.669 3051-3051/? W/KeyboardModeManager: KeyboardModeManager.setInputView():359 setInputView() : inputView = com.google.android.apps.inputmethod.libs.framework.core.InputView{cb5f35e V.E...... ......ID 0,0-1080,2022}
2020-10-12 00:20:43.672 3051-3051/? I/ConversationToQueryExtension: ConversationToQueryExtension.isEnabledForHostApp():254 Conv2Query not enabled due to current app [com.nghianguyen.obee_android.debug] not in whitelist
2020-10-12 00:20:43.672 3051-3051/? I/ConversationToQueryExtension: ConversationToQueryExtension.onActivate():165 onActivate() : Disabled by unsupported host app