1、键盘遮挡输入框;
2、全屏或沉浸式模式下,键盘导致标题栏上移;
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cl_e0"
android:orientation="vertical">
<!--标题栏-->
<com.kedacom.statusbar.widget.StatusBarHeightView
android:id="@+id/statusbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/icon_header_bg"
android:gravity="center"
android:orientation="vertical"
app:use_type="use_padding_top">
<include
android:id="@+id/inclue"
layout="@layout/common_title_layout" />
</com.kedacom.statusbar.widget.StatusBarHeightView>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@color/cl_333"
android:padding="14dp">
</android.support.constraint.ConstraintLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="10dp"
android:background="@color/white"
android:padding="14dp">
<EditText
android:id="@+id/et_contact"
android:layout_width="260dp"
android:layout_height="38dp"
android:layout_alignParentBottom="true"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:inputType="number"
android:maxLength="11"
android:paddingStart="11dp"
android:textColor="@color/cl_333"
android:textColorHint="@color/cl_999"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
在activity的onCreate方法中调用:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN |
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
//解决键盘档住输入框
SoftHideKeyBoardUtil.assistActivity(this);
注意事项:
1、布局文件中使用ScrollView嵌套需要滚动的布局(标题栏以下);
2、需要设置当前页面输入法模式:SOFT_INPUT_ADJUST_RESIZE(必须);注意不用受BaseActivity中的配置干扰;
特别说明(个人需求):
主页面使用了FragmentViewPagerTabLayout(内部是ViewPager),SoftHideKeyBoardUtil方法会导致键盘顶起底部导航栏,所以没有在BaseActivity中调用该方法。
本文地址:https://blog.csdn.net/zhijiandedaima/article/details/107494398
如对本文有疑问, 点击进行留言回复!!
android RecyclerView checkbox复用解决
Android Q Input (1) -- InputManagerService启动
android -- ndk (stack corruption detected)
Android Span富文本图文混排 - ImageSpan(图文垂直居中)
网友评论