安卓的EditText保持隐藏键盘背后 [英] Android: EditText stays hidden behind the keyboard

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

问题描述

在写这个问题我已经通过了如下回答/文章阅读:

  1. <一个href="http://stackoverflow.com/questions/3295672/android-soft-keyboard-covers-edittext-field">Android软键盘覆盖的EditText场
  2. Android键盘掩盖的EditText
  3. <一个href="http://developer.android.com/resources/articles/on-screen-inputs.html">http://developer.android.com/resources/articles/on-screen-inputs.html
  4. 软键盘有重叠的EditText场

Android的软键盘默认情况下进行平移,这意味着它会保持键盘上面的所有可编辑区域设置。然而,它不泛足够。当我运行它,preSS的EditText上是接近屏幕的底部,键盘的出现和的EditText上移,但还不足以能够看到的是什么类型的吧。我已经使用/试过如下:

  1. 安卓windowSoftInputMode =adjustPan的活动的清单。这并没有区别。我也试图把 adjustUnspecified adjustResize 太值。他们没有工作。

  2. &LT;使用-SDK安卓的minSdkVersion =3/&GT; 在清单文件。我的应用针对性的SDK 2.1及以上。即使这样,我试了一下,并没有工作。

  3. 使用滚动型。也不行。

有没有办法来手动管理多少淘洗的时候不特定的EditText是pressed键盘做的。

下面是我的XML文件。

 &LT; RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:后台=#FFFFFF&GT;

    &LT; ImageView的
    机器人:ID =@ + ID /头
    机器人:layout_width =320dip
    机器人:layout_height =86dip
    机器人:背景=@可绘制/ header_bg&GT;
    &LT; / ImageView的&GT;

    &LT; ImageView的
    机器人:layout_width =320dip
    机器人:layout_height =200dip
    机器人:layout_alignParentBottom =真
    机器人:背景=@可绘制/ bg1_btm&GT;
    &LT; / ImageView的&GT;

        &LT; TextView的Andr​​oid版本:文本=主机名
        机器人:ID =@ + ID / lbl_hostname
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID /头/&GT;

        &LT; TextView的Andr​​oid版本:文本=(当前)
        机器人:ID =@ + ID / lbl_hostname_current
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_toRightOf =@ ID / lbl_hostname
        机器人:layout_below =@ ID /头/&GT;

        &LT; EditText上的android:文本=的EditText
        机器人:ID =@ + ID / editText_hostname
        机器人:layout_below =@ ID / lbl_hostname
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:最大长度=25&GT;
        &LT; /的EditText&GT;

        &LT; TextView的Andr​​oid版本:文本=注册网址
        机器人:ID =@ + ID / lbl_registration
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / editText_hostname/&GT;

        &LT; TextView的Andr​​oid版本:文本=(当前)
        机器人:ID =@ + ID / lbl_registration_current
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / editText_hostname
        机器人:layout_toRightOf =@ ID / lbl_registration/&GT;

        &LT; TextView的Andr​​oid版本:文本=HTTP://
        机器人:ID =@ + ID / lbl_url_ preFIZ
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / lbl_registration
        机器人:paddingTop =10dip/&GT;

        &LT; EditText上的android:文本=的EditText
        机器人:ID =@ + ID / editText_registration
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_toRightOf =@ ID / lbl_url_ preFIZ
        机器人:layout_below =@ ID / lbl_registration&GT;
        &LT; /的EditText&GT;

        &LT; TextView的Andr​​oid版本:文本=聊天
        机器人:ID =@ + ID / lbl_chat
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / editText_registration/&GT;

        &LT; TextView的Andr​​oid版本:文本=(当前)
        机器人:ID =@ + ID / lbl_chat_current
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / editText_registration
        机器人:layout_toRightOf =@ ID / lbl_chat/&GT;

        &LT; EditText上的android:文本=的EditText
        机器人:ID =@ + ID / editText_chat
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / lbl_chat&GT;
        &LT; /的EditText&GT;

        &LT; TextView的Andr​​oid版本:文本=SSID
        机器人:ID =@ + ID / lbl_ssid
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / editText_chat/&GT;

        &LT; TextView的Andr​​oid版本:文本=(当前)
        机器人:ID =@ + ID / lbl_ssid_current
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / editText_chat
        机器人:layout_toRightOf =@ ID / lbl_ssid
        /&GT;

        &LT; EditText上的android:文本=的EditText
        机器人:ID =@ + ID / editText_ssid
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / lbl_ssid
        机器人:MAXLINES =1
        机器人:inputType =文本
        机器人:layout_marginBottom =25dip&GT;
        &LT; /的EditText&GT;

        &LT;按钮机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:ID =@ + ID / ButtonSave
        机器人:文本=保存
        机器人:layout_below =@ ID / editText_ssid
        机器人:layout_alignParentLeft =真正的&GT;
        &LT; /按钮&GT;

        &LT;按钮的android:文本=继续
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_width =WRAP_CONTENT
        机器人:ID =@ + ID / ButtonContinue
        机器人:layout_below =@ ID / editText_ssid
        机器人:layout_alignParentRight =真正的&GT;
        &LT; /按钮&GT;

&LT; / RelativeLayout的&GT;
 

解决方案

尝试

 安卓windowSoftInputMode =adjustResize
 

对我来说工作得很好

Before writing this question I have read through the following answers/articles:

  1. Android soft keyboard covers edittext field
  2. Android keyboard obscures EditText
  3. http://developer.android.com/resources/articles/on-screen-inputs.html
  4. Soft Keyboard Overlapping with EditText Field

The Android soft keyboard is set by default to pan which means it will keep all the editable regions above the keyboard. However it does not pan enough. When I run it and press the edittext that is close to the bottom of the screen, the keyboard comes up and edittext is moved up but not enough to be able to see what is being typed in it. I have used/tried the following:

  1. android:windowSoftInputMode="adjustPan" in the manifest of the Activity. This made no difference. I have also tried putting values of adjustUnspecified and adjustResize too. None of them works.

  2. <uses-sdk android:minSdkVersion="3" /> in the manifest file. My application is targetted for sdk 2.1 and above. Even though, I tried it and did not work.

  3. Using a ScrollView. Does not work either.

Is there a way to manually manage how much "panning" does a keyboard do when a specific edittext is pressed.

Below is my xml file.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:background="#ffffff">       

    <ImageView 
    android:id="@+id/header"
    android:layout_width="320dip"
    android:layout_height="86dip"
    android:background="@drawable/header_bg">
    </ImageView>

    <ImageView 
    android:layout_width="320dip"
    android:layout_height="200dip"
    android:layout_alignParentBottom="true"
    android:background="@drawable/bg1_btm">
    </ImageView>

        <TextView android:text="Hostname" 
        android:id="@+id/lbl_hostname"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/header"/>

        <TextView android:text="(Current)" 
        android:id="@+id/lbl_hostname_current"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/lbl_hostname"
        android:layout_below="@id/header" />

        <EditText android:text="EditText" 
        android:id="@+id/editText_hostname" 
        android:layout_below="@id/lbl_hostname"  
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:maxLength="25">
        </EditText>

        <TextView android:text="Registration URL" 
        android:id="@+id/lbl_registration"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/editText_hostname" />

        <TextView android:text="(Current)" 
        android:id="@+id/lbl_registration_current"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/editText_hostname"
        android:layout_toRightOf="@id/lbl_registration" />

        <TextView android:text="http://" 
        android:id="@+id/lbl_url_prefiz"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/lbl_registration"
        android:paddingTop="10dip" />

        <EditText android:text="EditText" 
        android:id="@+id/editText_registration" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_toRightOf ="@id/lbl_url_prefiz"
        android:layout_below="@id/lbl_registration">
        </EditText>

        <TextView android:text="Chat" 
        android:id="@+id/lbl_chat"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/editText_registration"/>

        <TextView android:text="(Current)" 
        android:id="@+id/lbl_chat_current"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/editText_registration"
        android:layout_toRightOf="@id/lbl_chat"/>

        <EditText android:text="EditText" 
        android:id="@+id/editText_chat" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/lbl_chat">
        </EditText>

        <TextView android:text="SSID" 
        android:id="@+id/lbl_ssid"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/editText_chat" />

        <TextView android:text="(Current)" 
        android:id="@+id/lbl_ssid_current"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_below="@id/editText_chat"
        android:layout_toRightOf="@id/lbl_ssid"
        />

        <EditText android:text="EditText" 
        android:id="@+id/editText_ssid" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/lbl_ssid"
        android:maxLines="1"
        android:inputType="text"
        android:layout_marginBottom="25dip">
        </EditText> 

        <Button android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/ButtonSave" 
        android:text="Save" 
        android:layout_below="@id/editText_ssid"
        android:layout_alignParentLeft="true">
        </Button>

        <Button android:text="Continue" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:id="@+id/ButtonContinue" 
        android:layout_below="@id/editText_ssid" 
        android:layout_alignParentRight="true">
        </Button>

</RelativeLayout>

解决方案

Try

android:windowSoftInputMode="adjustResize"  

worked fine for me :)

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

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