键盘显示隐藏了Android布局 [英] Android layout hidden on keyboard show

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

问题描述

我的布局有一个奇怪的问题.当我点击 EditText 时,会显示键盘,但是当我点击隐藏键盘时,我的 EditText 会停留在底部 em>,键盘隐藏和 EditText 会在我要输入文本时应显示的位置上.当我再次点击时,会显示键盘,并且 EditText 会落在键盘后面...

 < RelativeLayoutandroid:layout_width ="match_parent"android:layout_height ="match_parent">< ScrollViewandroid:layout_width ="match_parent"android:layout_height ="fill_parent"android:above ="@ + id/rl_commands">< TextViewandroid:layout_width ="match_parent"android:layout_height ="wrap_content"/></ScrollView>< RelativeLayoutandroid:layout_width ="match_parentandroid:layout_height ="24dp"android:id ="@ + id/rl_commands"android:alignParentBottom ="true">< EditText............/><按钮.........../></RelativeLayout></RelativeLayout> 

也在 manifest.xml 中添加了 adjustResize ,但问题仍然存在....我想要的是当我点击(焦点) EditText 和键盘显示, RelativeLayout 上去查看我输入的内容.然后在键盘隐藏后再次调整 RelativeLayout 的大小,然后 RelativeLayout 转到屏幕底部.就像充满活力...

解决方案

在manifest.xml文件内的活动标签中添加此行

  android:windowSoftInputMode = adjustPan 

有关更多信息,请参见: Android文档

I have a strange problem with my layout. When i tap on EditText, keyboard is shown but my EditText stay on bottom, when I tap on back to hide keyboard, keyboard hides and EditText go up where it should be when i want to input text. When I tap again, keyboard is shown and EditText goes down behind the keyboard...

<RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      >
     <ScrollView
          android:layout_width="match_parent"
          android:layout_height="fill_parent"
          android:above="@+id/rl_commands">
          <TextView
               android:layout_width="match_parent"
               android:layout_height="wrap_content"/>
    </ScrollView>
    <RelativeLayout
          android:layout_width="match_parent
          android:layout_height="24dp"
          android:id="@+id/rl_commands"
          android:alignParentBottom="true">
          <EditText
            ............/>
          <Button
           .........../>
 </RelativeLayout>
</RelativeLayout>

Also in manifest.xml I added adjustResize but problem stays.... What i want is that when I tap(focus) EditText and keyboard shows, RelativeLayout go up to see what I am typing. And after keyboard hide to resize RelativeLayout again and RelativeLayout go to bottom of screen. Like in viber...

解决方案

Add this line in activity tag inside manifest.xml file

android:windowSoftInputMode=adjustPan

for more you can refer :Android Documentation

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

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