今天突然发现adjustResize 在5.0与4.0上键盘弹出遮挡edittext效果不同,即在5.0上键盘把编辑框挡住了,但4.0上正常,键盘把编辑框撑上来了。后来发现与Translucent模式有关,解决办法是在根布局上加上fitsSystemWindow="true"即可:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#f0f0f0" android:fitsSystemWindows="true" android:orientation="vertical"> <ScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#f0f0f0" android:scrollbars="none"> <LinearLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#f0f0f0" android:orientation="vertical" android:paddingTop="15dp"> </LinearLayout> </ScrollView> </LinearLayout>