Подтвердить что ты не робот

Android - мягкая клавиатура выталкивает макет моей активности из экрана

Мой макет активности показан ниже.

<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>

Таким образом, окно поиска фиксируется в нижней части экрана.

Но когда пользователь нажимает на EditText, Soft Keyboard выводит и выталкивает макет из экрана, кроме окна поиска.

Я только начинаю с Android, так что я делаю что-то неправильно здесь?

4b9b3361

Ответ 1

Попробуйте добавить следующее для своей деятельности в манифест:

android:windowSoftInputMode="adjustPan"

Ответ 2

Для интересующих вас разница между android:windowSoftInputMode="adjustPan" и android:windowSoftInputMode="adjustResize":

"adjustResize"

Окно активности изменено, чтобы освободить место для экранной клавиатуры.

"adjustPan"

Содержимое окна активности автоматически запускается, так что текущий фокус никогда не блокируется клавиатурой. Это значит, что пользователь может видеть, что они набирают. Это, как правило, менее желательно, чем изменение размера, поскольку пользователю может понадобиться закрыть мягкую клавиатуру, чтобы получить и взаимодействовать с затененными частями окна.

Документация для Android

Цитированная ссылка

Ответ 3

@Raj Если вы работаете с вкладкой, вам нужно добавить

android:windowSoftInputMode="adjustPan"

на Activity, где вы добавляете вкладки, это, скорее всего, будет вашей активностью запуска.

Вот фрагмент моего кода

<activity
   android:label="@string/app_name"
   android:name=".MainActivity" android:windowSoftInputMode="adjustPan">
   <intent-filter >
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>