0
当对焦EditText
并且软键盘被打开时,它会在我的NavigationView
布局(参见屏幕截图)中推动我的headerLayout
。 我假设它与android:fitsSystemWindows="true"
有关nav_header_navigation.xml
的RelativeLayout
。如果我删除它,内容不会被推高,但它不像以前那样正确地适合屏幕。 有什么办法解决这个问题?软键盘将NavigationView的headerLayout向上推
- 1截图:关闭键盘,与
android:fitsSystemWindows="true"
- 第二截图:打开键盘,用
android:fitsSystemWindows="true"
- 3截图:打开键盘,无需
android:fitsSystemWindows="true"
代码:
<!-- activity.xml -->
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<LinearLayout ../>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:itemTextColor="@color/navigation"
app:itemIconTint="@color/navigation"
app:app="@layout/nav_header_navigation"
app:menu="@menu/navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
<!-- nav_header_navigation.xml -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="@+id/nav_header_navigation_avatar"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_big"
android:layout_marginTop="@dimen/margin_big"
android:src="@drawable/ic_edit_white_24dp"
android:layout_alignParentRight="true"/>
<LinearLayout .../>
</RelativeLayout>
你是否将'android:windowSoftInputMode =“adjustResize”'应用于你的活动? – azizbekian
同样的结果。 'adjustPan'就是一种解决方案,尽管它并不完美,因为菜单根本看不到。 – Chris
您是否找到解决方案?我正在处理同样的问题 – dumazy