2009-12-17 2 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 для той же проблемы..pls help if u? – shyam

ответ

14

Вы должны быть в состоянии контролировать, что в файле манифеста, добавив андроид: windowSoftInputMode = атрибут «adjustPan» к элементу деятельности. См. windowSoftInputMode documentation и blog post, объясняя это более подробно.

+1

Это похоже на правильный путь. Я попробовал что-то еще, когда у меня была такая же проблема. Я помещаю весь макет внутри прокрутки. Поэтому, когда отображается мягкая клавиатура, полосы прокрутки настраиваются, что делает видимыми нижние виджеты. Это может быть грубый взлом, он работал FWIW. – Jayesh

Смежные вопросы