2009-12-17 40 views
3

在我的布局中,屏幕底部有一个TextView。问题是,当我点击文本框内键入内容时,键盘覆盖了文本框,导致我无法看到发生了什么......有没有解决方案?这是我的布局......Android:当键盘弹出时,布局不可见。我该如何解决这个问题?

<?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> 
+0

嘿你是否发现任何soln相同的问题..请帮助如果你? – shyam 2011-10-19 07:57:15

回答

14

你应该能够控制在清单文件中,通过添加机器人:windowSoftInputMode =“adjustPan”属性的活动元素。见windowSoftInputMode documentationblog post更详细地解释这一点。

+1

这看起来像是正确的路要走。当我遇到同样的问题时,我尝试了其他的东西。我把整个布局放在滚动视图中。因此,当软键盘可见时,滚动条会自行调整,从而使最底部的小部件可见。这可能是一个粗糙的黑客,它工作的FWIW。 – Jayesh 2009-12-19 14:41:42