软键盘覆盖EditText下方的TextView
Soft keyboard covers TextView below EditText
我在 EditText 下方放置了一个 TextView 以显示后者的字符数。这是 EditText 未处于焦点时的样子。
当 EditText 处于焦点时:
如您所见,“7/500”已被 TextView 覆盖。
我的 XML activity:
<ScrollView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="20dp"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:id="@+id/display_photo"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/caption_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/et_start_photo_story_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:gravity="bottom"
android:maxLength="500"
android:paddingBottom="15dp"
android:privateImeOptions="nm"
android:textColor="@color/black" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/tv_character_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/grey700"
android:textSize="14sp" />
</LinearLayout>
</ScrollView>
我的清单中有这一行 android:windowSoftInputMode="adjustPan"
。我试过更改 ImageView 的高度,但当 EditText 处于焦点时字符数仍然隐藏。
而不是设置为
android:windowSoftInputMode="adjustPan"
尝试设置为
android:windowSoftInputMode="adjustResize"
这将使您的视图在 edittext 获得焦点时可滚动。
如果您使用 com.google.dagger:hilt-android
之类的依赖注入框架,请将 android:windowSoftInputMode="adjustPan|adjustResize"
放在清单的应用程序部分而不是 activity 部分。
我在 EditText 下方放置了一个 TextView 以显示后者的字符数。这是 EditText 未处于焦点时的样子。
当 EditText 处于焦点时:
如您所见,“7/500”已被 TextView 覆盖。
我的 XML activity:
<ScrollView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="20dp"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:id="@+id/display_photo"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/caption_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/et_start_photo_story_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:gravity="bottom"
android:maxLength="500"
android:paddingBottom="15dp"
android:privateImeOptions="nm"
android:textColor="@color/black" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/tv_character_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/grey700"
android:textSize="14sp" />
</LinearLayout>
</ScrollView>
我的清单中有这一行 android:windowSoftInputMode="adjustPan"
。我试过更改 ImageView 的高度,但当 EditText 处于焦点时字符数仍然隐藏。
而不是设置为
android:windowSoftInputMode="adjustPan"
尝试设置为
android:windowSoftInputMode="adjustResize"
这将使您的视图在 edittext 获得焦点时可滚动。
如果您使用 com.google.dagger:hilt-android
之类的依赖注入框架,请将 android:windowSoftInputMode="adjustPan|adjustResize"
放在清单的应用程序部分而不是 activity 部分。