选中时键盘隐藏的EditText [英] Keyboard hides EditText when selected

查看:220
本文介绍了选中时键盘隐藏的EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面对其中键盘隐藏时EDITTEXT被选择为第二时间EDITTEXT一个问题,在第一时间EDITTEXT选择了键盘的行为与预期。

当我设置EDITTEXT输入类型为NumberDecimal,但是当它被设置为默认键盘行为,通常还只出现该问题。

我曾尝试以下没有成功:


  

安卓windowSoftInputMode =adjustResize


下面

从布局文件中的一个片段。

 <的LinearLayout
                机器人:layout_width =match_parent
                机器人:layout_height =30dp
                机器人:layout_marginTop =20dp
                机器人:重力=center_vertical
                机器人:方向=横向
                机器人:weightSum =1>                <的TextView
                    机器人:layout_width =0dp
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_gravity =中心
                    机器人:layout_marginLeft =10dp
                    机器人:layout_weight =0.25
                    机器人:背景=@绘制/ rounded_left_selected
                    机器人:比重=中心
                    机器人:文字=@字符串/量
                    机器人:文字颜色=@色/白
                    机器人:TEXTSIZE =17dp                    机器人:文字样式=大胆/>                <的EditText
                    机器人:ID =@ + ID / TRANSFER_AMOUNT
                    机器人:layout_width =0dp
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =0.55
                    机器人:背景=@绘制/ white_unrounded_edittext
                    机器人:EMS =10
                    机器人:比重=中心
                    机器人:提示=@字符串/ hint_amount
                    机器人:最大长度=15
                    机器人:文字颜色=@彩色/ blue_light
                    机器人:TEXTSIZE =17dp
                    安卓的inputType =numberDecimal/>                <的TextView
                    机器人:ID =@ + ID / trans_amount_cur
                    机器人:layout_width =0dp
                    机器人:layout_height =match_parent
                    机器人:layout_weight =0.12
                    机器人:背景=@绘制/ round_right_selected
                    机器人:比重=中心
                    机器人:文字=JOD
                    机器人:文字颜色=@色/白
                    机器人:TEXTSIZE =17dp/>
            < / LinearLayout中>


解决方案

刚卸下的EditText的严重性,这似乎是一个错误。

 <的EditText
                机器人:ID =@ + ID / TRANSFER_AMOUNT
                机器人:layout_width =0dp
                机器人:layout_height =FILL_PARENT
                机器人:layout_weight =0.55
                机器人:背景=@绘制/ white_unrounded_edittext
                机器人:EMS =10
                机器人:提示=@字符串/ hint_amount
                机器人:最大长度=15
                机器人:文字颜色=@彩色/ blue_light
                机器人:TEXTSIZE =17dp
                安卓的inputType =numberDecimal/>

I am facing an issue where the keyboard hides an editText when the editText is selected for the second time, the first time editText is selected the keyboard behaves as expected.

The issue only occurs when I set the editText input type to "NumberDecimal" but when it's set to "Default" the keyboard behaves normally as well.

I have tried the following without success:

android:windowSoftInputMode="adjustResize"

below is a snippet from the layout file

 <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:layout_marginTop="20dp"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:weightSum="1">

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center"
                    android:layout_marginLeft="10dp"
                    android:layout_weight="0.25"
                    android:background="@drawable/rounded_left_selected"
                    android:gravity="center"
                    android:text="@string/amount"
                    android:textColor="@color/white"
                    android:textSize="17dp"

                    android:textStyle="bold" />

                <EditText
                    android:id="@+id/transfer_amount"
                    android:layout_width="0dp"
                    android:layout_height="fill_parent"
                    android:layout_weight="0.55"
                    android:background="@drawable/white_unrounded_edittext"
                    android:ems="10"
                    android:gravity="center"
                    android:hint="@string/hint_amount"
                    android:maxLength="15"
                    android:textColor="@color/blue_light"
                    android:textSize="17dp"
                    android:inputType="numberDecimal"/>

                <TextView
                    android:id="@+id/trans_amount_cur"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="0.12"
                    android:background="@drawable/round_right_selected"
                    android:gravity="center"
                    android:text="JOD"
                    android:textColor="@color/white"
                    android:textSize="17dp" />
            </LinearLayout>

解决方案

Just remove the gravity on edittext, it seems to be a bug.

<EditText
                android:id="@+id/transfer_amount"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="0.55"
                android:background="@drawable/white_unrounded_edittext"
                android:ems="10"
                android:hint="@string/hint_amount"
                android:maxLength="15"
                android:textColor="@color/blue_light"
                android:textSize="17dp"
                android:inputType="numberDecimal"/>

这篇关于选中时键盘隐藏的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆