0

Android when I click on the edit text at bottom of my layout the complete screen moves up in full-screen Activity

When key board is hidden

when keyboard is up the layout at top used to move over the screen but i want the to layout shown

When keyboard is up the layout at top used to move

This my layout code

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/layout_chat_container"
    style="@style/MatchParent"
    tools:ignore="RtlHardcoded">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/ll_action"
        android:orientation="vertical">
        <RelativeLayout
            android:id="@+id/navbar"
            android:layout_width="fill_parent"
            android:layout_height="76dp"
            android:visibility="visible"
            >
            <LinearLayout
                android:id="@+id/ll_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:background="@drawable/statusbar"></LinearLayout>
            <View
                android:id="@+id/line"
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:background="#ffff01"
                android:layout_below="@+id/ll_view"/>

            <LinearLayout
                android:id="@+id/ll_back_button"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:visibility="visible"
                android:layout_marginTop="25dp"
                android:orientation="vertical">

            </LinearLayout>
            <RelativeLayout
                android:layout_width="50dp"
                android:layout_alignParentRight="true"
                android:layout_marginRight="5dp"
                android:layout_below="@+id/line"
                android:onClick="onStartNewChatClick"
                android:layout_height="match_parent">
                <ImageView
                    android:id="@+id/fab_dialogs_new_chat"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:background="@drawable/qb_info"
                    android:visibility="visible"
                    android:layout_gravity="center"
                    android:layout_centerInParent="true"


                    />
            </RelativeLayout>
            <RelativeLayout
                android:layout_width="50dp"
                android:layout_alignParentLeft="true"
                android:layout_marginLeft="5dp"
                android:layout_below="@+id/line"
                android:onClick="onStartNewChatBack"
                android:layout_height="match_parent">
                <ImageView
                    android:id="@+id/img_back"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:background="@drawable/qb_back"
                    android:visibility="visible"
                    android:layout_gravity="center"
                    android:layout_centerInParent="true"


                    />
            </RelativeLayout>
        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_centerInParent="true"
            android:layout_below="@+id/line"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/txtv_myuserloginname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:text="USER"
                android:layout_marginTop="10dp"
                android:layout_centerHorizontal="true"
                android:textColor="#222222"
                android:gravity="center"
                android:textSize="15dp"
                />
        </RelativeLayout>
        </RelativeLayout>
        <View
            android:id="@+id/view"
            android:layout_below="@+id/navbar"
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:background="#ffff01"/>
    </LinearLayout>

    <se.emilsjolander.stickylistheaders.StickyListHeadersListView
        android:id="@+id/list_chat_messages"
        style="@style/ListViewWithoutDividerStyle"
        android:layout_above="@+id/layout_attachment_preview_container"
        android:layout_below="@+id/ll_action"
        android:listSelector="@android:color/transparent"
        android:stackFromBottom="true" />

    <ProgressBar
        android:id="@+id/progress_chat"
        style="@style/CenterProgressBarStyle" />

    <LinearLayout
        android:id="@+id/layout_attachment_preview_container"
        style="@style/MatchWidth"
        android:layout_height="96dp"
        android:layout_above="@+id/layout_chat_send_container"
        android:background="?attr/colorPrimary"
        android:orientation="vertical"
        android:visibility="gone">

        <View
            android:id="@+id/divider_chat_attachments"
            style="@style/HorizontalDividerStyle" />

        <com.quickblox.sample.chat.ui.widget.AttachmentPreviewAdapterView
            android:id="@+id/adapter_view_attachment_preview"
            style="@style/MatchWidth" />
    </LinearLayout>

    <View
        android:id="@+id/divider_chat"
        style="@style/HorizontalDividerStyle"
        android:layout_above="@+id/layout_chat_send_container" />

    <LinearLayout
        android:id="@+id/layout_chat_send_container"
        style="@style/MatchWidth"
        android:layout_alignParentBottom="true"
        android:background="?attr/colorPrimary"
        android:orientation="horizontal">

        <ImageButton
            android:id="@+id/button_chat_attachment"
            style="@style/BorderlessImageButtonStyle"
            android:layout_gravity="center_vertical"
            android:onClick="onAttachmentsClick"
            android:src="@drawable/ic_action_attachment" />

        <EditText
            android:id="@+id/edit_chat_message"
            style="@style/WeightWidth"
            android:layout_height="wrap_content"
            android:hint="@string/chat_edit_text_hint"
            android:inputType="textShortMessage"
            android:maxLength="1024" />

        <ImageButton
            android:id="@+id/button_chat_send"
            style="@style/BorderlessImageButtonStyle"
            android:layout_gravity="center_vertical"
            android:onClick="onSendChatClick"
            android:src="@drawable/ic_send"
            android:text="@string/chat_send" />
    </LinearLayout>
</RelativeLayout>

Java code

   getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

Manifest

  <activity
        android:name=".ui.activity.ChatMenu"
        android:screenOrientation="portrait"
        android:theme="@style/ChatActivityTheme"
        android:windowSoftInputMode="stateHidden|adjustResize" />

Style

<style name="ChatActivityTheme" parent="AppTheme">
        <item name="android:windowBackground">@color/background_chat_color</item>

    </style>

how to avoid top layout not to move up with keyboard but the edit text should move with keyboard up in FullScreen activity

Bharat Kumar Emani
  • 3,436
  • 3
  • 16
  • 30

2 Answers2

0

have you tried this?

<activity
   ...
   android:windowSoftInputMode="adjustPan"> 
</activity>

doc here

then your whole layout will NOT resize. if you want to move only your EditText you have to measure size of keyboard/your available screen (cause it will be smaller when keyboard present)

there is no "standard" way to prevent resizing and sticking only piece of View to top of keyboard (as far as I know)

snachmsm
  • 17,866
  • 3
  • 32
  • 74
  • can u please tell me how to do that – Bharat Kumar Emani Dec 13 '16 at 10:28
  • check out [this question and answer](http://stackoverflow.com/questions/16788959/is-there-any-way-in-android-to-get-the-height-of-virtual-keyboard-of-device), and move your `EditText` every time when size is changed – snachmsm Dec 13 '16 at 10:31
  • Can you give me any example for that it is important for me – Bharat Kumar Emani Dec 14 '16 at 10:35
  • sorry, I can't... I don't have any example and writing this from scratch is laborious. also: there is a lot of keybaords in market, not all are opening from bottom and takes about half of screen. some are popping in center of screen (with padding on edges), some ale consuming whole screen and presenting own text field with preview (especially in horizontal). there is sooo much scenarios that I doubt it is possible to cover all of them... why you don't like `adjustResize`? it's most "UX-able" way for showing keyboard, especially for messaging app (like screen), your way will cover content – snachmsm Dec 14 '16 at 12:05
0

try using this on your androidmanifest.xml

 <activity
    ...
    android:windowSoftInputMode="adjustResize" />
  • he is using this currently, he _don't_ want to resize whole layout, only stick piece of layout on top of keyboard – snachmsm Dec 13 '16 at 10:29