1、期望的效果:
- 输入法弹起时,背景图不要向上移动或压缩
- 输入法弹起时,不要遮挡输入框,输入框可以向上移动;
2、实现方式:
1、在AndroidManifest.xml 中设置对应Activity的输入法模式:
android:windowSoftInputMode="adjustResize|stateHidden"
2、页面的背景不要设置在xml布局中,通过代码设置背景:
// 设置背景图片
getWindow().setBackgroundDrawableResource(R.drawable.loginbg);
3、使用ScrollView嵌套需要滚动的布局
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
// 布局
</LinearLayout>
</ScrollView>