Question

I'm doing a messaging screen in Android. Layout is LinearLayout.

Messaging Screen

But when keyboard is visible.

Keyboard visible

The proportion of layout in the bottom is messed. How can I force it to retain its proportion? Here is my layout file. I tried with adjustPan, the editText is visible but action bar is gone. I want to use adjustResize because I want action bar too but the editText is not visible anymore.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:flatui="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/background_grey"
        android:layout_weight="93" >

        <ListView android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView android:id="@android:id/empty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:textAppearance="@android:style/TextAppearance.Large"
            android:text="No chat history." />

    </LinearLayout>

    <LinearLayout android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_margin="5dp"
        android:layout_weight="7">

        <com.cengalabs.flatui.views.FlatEditText
            android:id="@+id/message"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:gravity="top"
            android:hint="Message"
            android:layout_marginRight="5dp"
            flatui:theme="Deep"
            flatui:fieldStyle="transparentBox"
            flatui:cornerRadius="3dip"/>

        <com.cengalabs.flatui.views.FlatButton
            android:id="@+id/sign_in_button"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="Send"
            android:layout_weight="1"
            flatui:theme="Deep"
            flatui:textAppearance="none"/>

    </LinearLayout>

</LinearLayout>
Was it helpful?

Solution

Try to use this layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:flatui="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/background_grey"
        android:layout_above="@+id/bottomToolbox">

        <ListView android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView android:id="@android:id/empty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:textAppearance="@android:style/TextAppearance.Large"
            android:text="No chat history." />

    </LinearLayout>

    <LinearLayout 
        android:id="@+id/bottomToolbox"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="5dp">

        <com.cengalabs.flatui.views.FlatEditText
            android:id="@+id/message"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:gravity="top"
            android:hint="Message"
            android:layout_marginRight="5dp"
            flatui:theme="Deep"
            flatui:fieldStyle="transparentBox"
            flatui:cornerRadius="3dip"/>

        <com.cengalabs.flatui.views.FlatButton
            android:id="@+id/sign_in_button"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="Send"
            android:layout_weight="1"
            flatui:theme="Deep"
            flatui:textAppearance="none"/>

    </LinearLayout>

</RelativeLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top