安卓:当弹出键盘,布局是无形的。我该如何解决这个问题? [英] Android: When the keyboard pops up, the layout is invisible. How do I solve this?
问题描述
在我的布局,有一个TextView在屏幕的底部。问题是,当我在文本框内单击以输入一些东西,键盘覆盖了文本框,一个结果,我不能看到发生了什么......对此有什么解决办法?这里是我的布局......
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / mainLayout
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@可绘制/ layout_bg
>
< ImageView的
机器人:ID =@ + ID / headerimg
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =左
机器人:paddingTop =5DP
机器人:paddingBottom会=5DP
机器人:以下属性来=5DP
机器人:SRC =@可绘制/ header_image
/>
<的LinearLayout
机器人:ID =@ + ID / secondaryLayout
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =320dip
机器人:layout_marginTop =5dip
机器人:layout_marginLeft =8DIP
机器人:layout_marginRight =8DIP
机器人:cacheColorHint =#00000000
>
<! - 一个ListView出现在这里 - >
< / LinearLayout中>
< RelativeLayout的
机器人:ID =@ + ID /消息
机器人:方向=横向
机器人:layout_width =300dip
机器人:layout_height =80dip
机器人:layout_gravity =中心
>
<的EditText
机器人:ID =@ + ID /的MessageText
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =230dip
机器人:layout_marginLeft =8DIP
机器人:layout_marginTop =8DIP
机器人:paddingBottom会=8DIP
机器人:以下属性来=15px的
机器人:提示=此类型的东西......>
< /的EditText>
<按钮
机器人:ID =@ + ID / MsgButton
机器人:layout_margin =0dip
机器人:layout_width =48dip
机器人:layout_toRightOf =@ ID /的MessageText
机器人:layout_height =48dip>
< /按钮>
< / RelativeLayout的>
< / LinearLayout中>
您应该能够控制在清单文件,加入机器人:windowSoftInputMode =adjustPan属性的活动要素。请参阅<一href="http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft">windowSoftInputMode文档和博客文章解释这个更详细
In my layout, there is a TextView at the bottom of the screen. The problem is that when I click inside the text box to type something, the keyboard covers the text box as a result of which I am not able to see what's happening... Is there any solution for this? Here's my layout...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/layout_bg"
>
<ImageView
android:id="@+id/headerimg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:src="@drawable/header_image"
/>
<LinearLayout
android:id="@+id/secondaryLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="320dip"
android:layout_marginTop = "5dip"
android:layout_marginLeft="8dip"
android:layout_marginRight="8dip"
android:cacheColorHint="#00000000"
>
<!-- A ListView appears here -->
</LinearLayout>
<RelativeLayout
android:id="@+id/message"
android:orientation="horizontal"
android:layout_width="300dip"
android:layout_height="80dip"
android:layout_gravity="center"
>
<EditText
android:id="@+id/MessageText"
android:layout_height="wrap_content"
android:layout_width="230dip"
android:layout_marginLeft="8dip"
android:layout_marginTop = "8dip"
android:paddingBottom = "8dip"
android:paddingLeft="15px"
android:hint="Type something here...">
</EditText>
<Button
android:id="@+id/MsgButton"
android:layout_margin="0dip"
android:layout_width="48dip"
android:layout_toRightOf="@id/MessageText"
android:layout_height="48dip">
</Button>
</RelativeLayout>
</LinearLayout>
You should be able to control that in the manifest file, by adding android:windowSoftInputMode="adjustPan" attribute to the activity element. See windowSoftInputMode documentation and a blog post explaining this in more detail.
这篇关于安卓:当弹出键盘,布局是无形的。我该如何解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!