Android - 软键盘将我的活动布局推到屏幕外 [英] Android - Soft Keyboard pushes layout of my activity out of screen

查看:17
本文介绍了Android - 软键盘将我的活动布局推到屏幕外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的activity的布局如下图.

My activity's layout is as shown below.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical">

   <FrameLayout android:id="@+id/title_bar"
      android:layout_width="fill_parent"
      android:layout_height="25dip"
      android:background="@drawable/bg_title" />

   <LinearLayout android:id="@+id/main"
      android:width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_weight="1">
         <ListView android:id="@+id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
         <TextView android:id="@+id/android:empty"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
      </FrameLayout>
   </LinearLayout>

   <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="50dip" >
      <EditText android:id="@+id/query"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" 
         android:hint="Enter some search terms"
         android:singleLine="true" 
         android:layout_weight="1" />
      <Button android:id="@+id/btn_hide"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:background="@drawable/btn_hide"
         android:layout_marginLeft="6dip" />
   </LinearLayout>
 </LinearLayout>

因此,搜索框固定在屏幕底部.

So, the search box is fixed to the bottom of the screen.

但是,当用户单击 EditText 时,软键盘会出现并将布局推出屏幕之外,搜索框除外.

But, when user clicks the EditText, Soft Keyboard shows up and pushes the layout out of the screen except the search box.

我刚刚开始使用 Android,所以我在这里做错了吗??

I'm just starting out with Android, so am I doing anything wrong here??

推荐答案

尝试在 Manifest 中为您的活动添加以下内容:

Try adding the following for your activity in Manifest:

android:windowSoftInputMode="adjustPan"

这篇关于Android - 软键盘将我的活动布局推到屏幕外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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