EditText 默认不获取焦点,弹出软键盘布局变形解决方案

简介: 关于弹出软键盘布局变形解决方案: 在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode="adjustPan" 在实际开发中,有的页面用到Edittext控件,这时候进入该页面可能会自动弹出输入法 这么显示不太友好,所以需要设置一下让Edittext默认不自动获取焦点。

关于弹出软键盘布局变形解决方案:

在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode="adjustPan"

在实际开发中,有的页面用到Edittext控件,这时候进入该页面可能会自动弹出输入法

这么显示不太友好,所以需要设置一下让Edittext默认不自动获取焦点。在网上查资料解决办法如下:

在EditText的父级控件中找一个,设置成

android:focusable="true"  
android:focusableInTouchMode="true"

<LinearLayout
	android:layout_width="match_parent"
	android:layout_height="74dp"
	android:focusable="true"
	android:focusableInTouchMode="true"
	android:gravity="center_vertical"
	android:orientation="horizontal"
	android:paddingLeft="20dip"
	android:paddingRight="20dip" >

	<TextView
		style="@style/BillDetailLabel"
		android:text="@string/takecar_car_kilometre" />

	<EditText
		android:id="@+id/my_bill_detail_takecar_car_kilometre_content"
		style="@style/BillDetailContent"
		android:layout_width="0dp"
		android:layout_marginLeft="10dp"
		android:layout_weight="1"
		android:gravity="left"
		android:inputType="number"
		android:maxLength="9" />

	<TextView
		style="@style/BillDetailLabel"
		android:layout_marginLeft="2dp"
		android:text="@string/kilometre" />

	<Button
		android:id="@+id/my_bill_detail_takepic_btn"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_marginLeft="10dp"
		android:background="@drawable/my_bill_detail_camera_icon_selector" />
</LinearLayout>

  开始会自动获取焦点的元素是 my_bill_detail_takecar_car_kilometre_content

 

当我在该 EditText 的父节点 LinearLayout 上面设置了

 

android:focusable="true"
android:focusableInTouchMode="true"

之后就不会启动这个画面默认启动输入法了

目录
相关文章
|
5月前
设置按钮背景为透明去掉button按钮左右两边的留白
设置按钮背景为透明去掉button按钮左右两边的留白
|
Android开发
Android点击空白区域,隐藏输入法软键盘
Android点击空白区域,隐藏输入法软键盘
595 0
|
Android开发 UED
完美解决android软键盘挡住输入框方法,还不顶标题栏
完美解决android软键盘挡住输入框方法,还不顶标题栏
1149 0
完美解决android软键盘挡住输入框方法,还不顶标题栏
|
XML 数据安全/隐私保护 Android开发
android如何让布局一直在键盘上方显示
在实际项目中,肯定会有输入数据的情况,这样就会用到键盘。
|
Android开发
Android控制软键盘的弹出和隐藏
弹出软键盘 前提:必须要有一个可以编辑的控件(EditText),并且当前已经获取焦点 /** * 弹出软键盘 */ public void openKeyboard(View view) { // 获取焦点 editText2.
1166 0
|
Android开发
Android笔记:软键盘弹出遮盖原来界面的布局控件
Android笔记:软键盘弹出遮盖原来界面的布局控件
142 0
|
Android开发
Android 自定义控件之SlidingMenuVertical顶部悬浮(垂直折叠抽屉,有滑动渐变回调,可自行添加渐变动画)
顶部悬浮(垂直折叠抽屉,有滑动渐变回调,可自行添加渐变动画)
2015 0

热门文章

最新文章