【发布时间】:2016-12-04 04:47:32
【问题描述】:
我在fragment 中使用EditText,它在constraintsLayout 中,但是当我输入超过屏幕长度的更多行时,editText 不会向上移动。
我尝试将“windowSoftInputMode”设置为“adjustPan”和“adjustResize”,尝试将“isScrollContainer”设置为真假。
我尝试使用scrollview 并将我的EditText 设置为其子级。但都有同样的问题。
我的活动不是全屏。
下面的代码是我的manifest
<activity
android:name=".MainActivity"
android:screenOrientation="userPortrait"
android:windowSoftInputMode="stateVisible|adjustPan">
以下代码是我的布局,它在约束布局中。
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textCapSentences|textAutoCorrect|textMultiLine|textWebEditText"
android:ems="10"
android:id="@+id/editText"
android:imeOptions="actionSend"
android:scrollHorizontally="false"
android:saveEnabled="true"
android:scrollbars="vertical"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="32dp"
app:layout_constraintHorizontal_bias="0.0"
android:isScrollContainer="false"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:hint="@string/writeYourPostHere"/>
这是我的片段的外观,当我用“行号”键入 20 行单词“testing”时,它没有向上移动,并且其余的单词(Testing 18,Testing 19,Testing 20)被隐藏了,即使我我仍在输入“测试 20”字样。我希望它向上移动并显示我输入的最后一个字。
我已经阅读了以下链接中的答案,但它们看起来都一样,无法解决我的问题。
EditText, adjustPan, ScrollView issue in android
adjustPan not preventing keyboard from covering EditText
Forcing adjustPan in activity containing ScrollView
Android EditText Multiline with SoftInputMode adjustPan
How to avoid soft keyboard pushing up my layout?
【问题讨论】:
标签: android android-fragments android-edittext