如何prevent该键盘隐藏我的EditText? [英] How to prevent that the keyboard hides my EditText?

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

问题描述

我在顶部有一个RelativeLayout的,那么下面我有一个ListView的中心,最后在底部我还有一个RelativeLayout的有一个EditText和一个按钮里面。

我想在ListView调整大小,当我点击的EditText和IME(虚拟键盘)出现。如果我把adjustResize在清单中,列表视图调整为留出空间为IME,但与EditText上的RelativeLayout的是以下信息由IME覆盖,我看不到我在写什么。如果我把adjustPan,键盘推手所有,ListView控件不能调整大小和我松顶部RelativeLayout的。

我的code:

 <的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=垂直
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:背景=@绘制/ application_background
    机器人:paddingLeft =15像素
    机器人:paddingRight =15像素
    机器人:paddingTop =15像素
    机器人:paddingBottom会=15px的>    < RelativeLayout的
        机器人:ID =@ + ID / rlyParentPost
        机器人:方向=垂直
        机器人:layout_width =450像素
        机器人:layout_height =85px
        机器人:背景=@绘制/ app_gradient_color
        机器人:layout_centerHorizo​​ntal =真正的>
        < ImageView的
            机器人:ID =@ + ID / imgUserOfParent
            机器人:layout_marginLeft =10px的
            机器人:layout_marginTop =10px的
            机器人:背景=@绘制/ userfeed
            机器人:layout_width =64PX
            机器人:layout_height =64PX
            机器人:layout_below =@ + ID / logoImg>
        < / ImageView的>
        <的TextView
            机器人:layout_below =@ + ID / logoImg
            机器人:layout_toRightOf =@ + ID / imgUserOfParent
            机器人:ID =@ + ID / lblNameOfParent
            机器人:TEXTSIZE =知识+
            机器人:文字样式=大胆
            机器人:layout_marginLeft =5dip
            机器人:layout_marginTop =11dip
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:文字颜色=#FFFFFF>
        < / TextView的>
        <的TextView
            机器人:layout_below =@ + ID / lblNameOfParent
            机器人:layout_toRightOf =@ + ID / imgUserOfParent
            机器人:ID =@ + ID / lblBodyOfParent
            机器人:文字颜色=#FFFFFF
            机器人:TEXTSIZE =知识+
            机器人:layout_marginLeft =5dip
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT>
        < / TextView的>
        <的TextView
            机器人:layout_below =@ + ID / lblBodyOfParent
            机器人:layout_toRightOf =@ + ID / imgUserOfParent
            机器人:ID =@ + ID / lblDateOfParent
            机器人:文字颜色=#70ccff
            机器人:TEXTSIZE =11像素
            机器人:layout_marginLeft =7dip
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT>
        < / TextView的>
    < / RelativeLayout的>    < RelativeLayout的
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ + ID / rlyParentPost
        机器人:ID =@ + ID / contentLayout>     < ListView控件
       机器人:isScrollContainer =真
         机器人:ID =@ + ID / lsvComments
         机器人:layout_height =515px
         机器人:layout_width =450像素
         机器人:背景=#FFFFFF
         机器人:listSelector =@绘制/ multi_white_color
         机器人:drawSelectorOnTop =假
         机器人:分=#9aa5ac
         机器人:cacheColorHint =#00000000
         机器人:dividerHeight =1px的>
     < /&的ListView GT;     < RelativeLayout的
         机器人:layout_width =WRAP_CONTENT
         机器人:layout_height =WRAP_CONTENT
         机器人:填充=5dip
         机器人:layout_below =@ + ID / lsvComments
         机器人:背景=@绘制/ app_gradient_comments
         机器人:ID =@ + ID / contentLayout>
         <的EditText
             安卓的inputType =TEXT
             机器人:ID =@ + ID / txtComment
             机器人:提示=你的工作吗?
             机器人:TEXTSIZE =的22px
             机器人:layout_marginLeft =8像素
             机器人:layout_height =72px
             机器人:layout_width =344px>
         < /&的EditText GT;
         <按钮
             机器人:layout_toRightOf =@ + ID / txtComment
             机器人:ID =@ + ID / cmdShare
             机器人:layout_width =79px
             机器人:layout_height =65px
             机器人:背景=@绘制/ feed_comments_multi_stage
             机器人:layout_marginLeft =7px的>
         < /按钮>
    < / RelativeLayout的>
   < / RelativeLayout的>
< / RelativeLayout的>


解决方案

如果您通过任何机会使用这样的:

  getWindow()setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)。

这可能会导致问题。我最初添加该行固定,其中状态栏向下推应用程序中的错误...但它也$ P $从向上推应用pvents键盘。

叹息。

I have a RelativeLayout at the top, then below i have a ListView in the center and finally at the bottom i have another relativeLayout with an EditText and a Button inside.

I want the ListView to resize when I click on the EditText and the IME(virtual keyboard) appears. If i put adjustResize in the manifest, the Listview is resized to leave space for the IME, but the RelativeLayout with the EditText that is below is covered by the IME and I can't see what I'm writing. If I put adjustPan, the keyboard pushs up all, the ListView is not resized and i loose the top RelativeLayout.

My Code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/application_background"
    android:paddingLeft="15px"
    android:paddingRight="15px"
    android:paddingTop="15px"
    android:paddingBottom="15px">

    <RelativeLayout
        android:id="@+id/rlyParentPost"
        android:orientation="vertical"
        android:layout_width="450px"
        android:layout_height="85px"
        android:background="@drawable/app_gradient_color"
        android:layout_centerHorizontal="true">
        <ImageView
            android:id="@+id/imgUserOfParent"
            android:layout_marginLeft="10px"
            android:layout_marginTop="10px"
            android:background="@drawable/userfeed"
            android:layout_width="64px"
            android:layout_height="64px"
            android:layout_below="@+id/logoImg">
        </ImageView>
        <TextView
            android:layout_below="@+id/logoImg"
            android:layout_toRightOf="@+id/imgUserOfParent"
            android:id="@+id/lblNameOfParent"
            android:textSize="17px"
            android:textStyle="bold"
            android:layout_marginLeft="5dip"
            android:layout_marginTop="11dip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#ffffff">
        </TextView>
        <TextView
            android:layout_below="@+id/lblNameOfParent"
            android:layout_toRightOf="@+id/imgUserOfParent"
            android:id="@+id/lblBodyOfParent"
            android:textColor="#ffffff"
            android:textSize="17px"
            android:layout_marginLeft="5dip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </TextView>
        <TextView
            android:layout_below="@+id/lblBodyOfParent"
            android:layout_toRightOf="@+id/imgUserOfParent"
            android:id="@+id/lblDateOfParent"
            android:textColor="#70ccff"
            android:textSize="11px"
            android:layout_marginLeft="7dip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </TextView>
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rlyParentPost"
        android:id="@+id/contentLayout">

     <ListView
       android:isScrollContainer="true"
         android:id="@+id/lsvComments"
         android:layout_height="515px"
         android:layout_width="450px"
         android:background="#ffffff"
         android:listSelector="@drawable/multi_white_color"
         android:drawSelectorOnTop="false"
         android:divider="#9aa5ac"
         android:cacheColorHint="#00000000"
         android:dividerHeight="1px">
     </ListView>

     <RelativeLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:padding="5dip"
         android:layout_below="@+id/lsvComments"
         android:background="@drawable/app_gradient_comments"
         android:id="@+id/contentLayout">
         <EditText
             android:inputType="text"
             android:id="@+id/txtComment"
             android:hint="What are you working on?" 
             android:textSize="22px"
             android:layout_marginLeft="8px"
             android:layout_height="72px"
             android:layout_width="344px">
         </EditText>
         <Button
             android:layout_toRightOf="@+id/txtComment"
             android:id="@+id/cmdShare"
             android:layout_width="79px"
             android:layout_height="65px"
             android:background="@drawable/feed_comments_multi_stage"
             android:layout_marginLeft="7px">
         </Button>
    </RelativeLayout> 
   </RelativeLayout>
</RelativeLayout>

解决方案

if you by any chance are using this:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

this can cause the problem. I originally added that line to fix a bug where the status bar pushes the app downward... but it also prevents the keyboard from pushing the app upward.

sigh.

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

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