有了类似edittext的布局之后,每次打开页面总是会弹出输入法,很影响美观。后来查了网上网友的建议,找到两种方法:1.在edittext的父布局加上android:focusable="true"和
android:focusableInTouchMode="true"的代码,2.在相同父布局下的相邻布局加上android:focusable="true"和android:focusableInTouchMode="true"代码。一般情况下这两种方法确实有效。但是在一个activity有多个edittext嵌套下,有时候是不管用了,输入法照样弹出来。
经过多次测试,发现在最大父布局中加入android:focusable="true"和android:focusableInTouchMode="true"代码,能很好解决之前不能解决的问题,暂时没有发现输入法弹出的现象。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context="com.example.dddd.MainActivity" >