How to keep some components fixed when you turn on the soft keyboard?

My application is a chat application, and its user interface:

Application title
View list
Chat, input field and submit button

But the problem is that when I click on the edit text, a soft keyboard appears and pushes everything, but I need a title so that it stays on the screen. I have added simplified problem images and user interface code here . (I cannot post multiple links or images in this post because I'm new to Stack Overflow.)

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:text="Header contents" android:layout_width="fill_parent" android:textSize="20sp" android:gravity="center_horizontal" android:layout_height="wrap_content" /> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> <EditText android:text="" android:layout_gravity="bottom" android:id="@+id/EditText01" android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText> </LinearLayout> 

Android has this requirement in the default messaging application.

Does anyone have any ideas?

+4
source share
3 answers

The question is quite old, but in any case, one way to fix this is to put everything under the heading in ScrollView.

Example:

 <!-- Both elements below are children of a parent RelativeLayout --> <RelativeLayout android:id="@+id/custom_action_bar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:isScrollContainer="false" > <!-- Header goes here. --> <!-- This part remains fixed even with the keypad popping up. --> </RelativeLayout> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/custom_action_bar" android:isScrollContainer="true" > <!-- Rest of the UI --> <!-- This part scrolls to accommodate the keyboard --> </ScrollView> 
+4
source

The solution described here is a solution. Your full-screen theme is responsible for Kamil Los being unable to reproduce your problem.

You need to configure the windowSoftInputMode action tag as described here .

Try adding the tag "android: windowSoftInputMode =" adjustResize "" to abusive activity in the application manifest.

+1
source

This is rather strange, because I created a new project, inserted your layout, and the title did not disappear in my case (neither in the 2.2 emulator, nor in 1.6).

-1
source

Source: https://habr.com/ru/post/1336921/


All Articles