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