0

I have an activity in which I am using the fragment. In fragment I have custom toolbar, a list and a EditTextView. When Keyboard visible in this Activity, it pushes up layout. How can I prevent the toolbar to be at its original position. Following code is written in my fragment:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_alert_main_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_hexa">

    <TextView
        android:id="@+id/channel_title"
        android:paddingLeft="10dp"
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:background="@color/black"
        android:textColor="@color/white"
        android:textSize="16sp"
        android:visibility="gone"
        android:layout_below="@id/layout_alert_top"
        android:layout_alignParentTop="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <RelativeLayout
        android:id="@+id/layout_alert_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="visible"
        android:background="@color/app_blue"
        android:orientation="horizontal">

        <RelativeLayout
            android:id="@+id/layout_channel_back_view"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:clickable="true"
            android:focusable="true">

            <ImageView
                android:id="@+id/title_bar_left_menu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@drawable/ic_menu_white_32"/>
        </RelativeLayout>

        <TextView
            android:id="@+id/tv_screen_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:text="@string/channel_title"
            android:layout_centerInParent="true"
            android:textSize="24sp"
            android:textColor="@color/white_text"/>

        <RelativeLayout
            android:id="@+id/channels_sliding_menu"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentRight="true"
            android:clickable="true"
            android:focusable="true">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@drawable/ic_tab_channels_white"/>
        </RelativeLayout>

    </RelativeLayout>

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_below="@+id/channel_title"
        android:isScrollContainer="false"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <RelativeLayout
            android:id="@+id/layout_list_alerts"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/zero_conversation"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="16sp"
                android:textColor="@color/dark_gray_text"
                android:layout_centerInParent="true"
                android:text="Empty"
                android:visibility="gone"/>

            <RelativeLayout
                android:id="@+id/layout_type_message"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_alignParentBottom="true"
                android:orientation="horizontal"
                android:background="@color/gray">

                <EditText
                    android:id="@+id/et_type_message"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_toLeftOf="@+id/layout_send_message"
                    android:background="@drawable/square_round_corners"
                    android:hint="Type your message.."
                    android:layout_marginTop="5dp"
                    android:layout_marginBottom="5dp"
                    android:layout_marginLeft="10dp"
                    android:padding="5dp"
                    android:singleLine="true"
                    android:textColor="@color/black"
                    android:textColorHint="@color/black"
                    android:textSize="16sp"/>

                <Button
                    android:id="@+id/layout_send_message"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:layout_alignParentRight="true"
                    android:padding="5dp"
                    android:textSize="16sp"
                    android:textStyle="bold"
                    android:background="@color/transparent"
                    android:textColor="@color/dark_gray_text"
                    android:layout_centerInParent="true"
                    android:text="Send"/>
            </RelativeLayout>

            <ListView
                android:id="@+id/conversation_list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@id/layout_type_message"
                android:divider="@null"
                android:listSelector="@color/transparent"
                android:stackFromBottom="true"
                android:transcriptMode="normal"
                />
        </RelativeLayout>

        <FrameLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:baselineAligned="false" >
        </FrameLayout>

        <ListView
            android:id="@+id/channels_list"
            android:background="@color/gray"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:divider="@null"
            android:layout_gravity="right"
            android:choiceMode="singleChoice" />
    </android.support.v4.widget.DrawerLayout>


</RelativeLayout>
Ehsan Anjum
  • 762
  • 8
  • 15

3 Answers3

0

Hello, Try to apply this attribute in Activity Tag in Manifest file and let me know if you can get your desired output or not. Okay.

 android:windowSoftInputMode="stateAlwaysHidden|adjustResize"

> XML file` :

<?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_alert_main_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFF">


    <RelativeLayout
        android:id="@+id/layout_alert_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:orientation="horizontal"
        android:visibility="visible">

        <RelativeLayout
            android:id="@+id/layout_channel_back_view"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:clickable="true"
            android:focusable="true">

            <ImageView
                android:id="@+id/title_bar_left_menu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="#FFFFFF" />
        </RelativeLayout>

        <TextView
            android:id="@+id/tv_screen_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:paddingBottom="10dp"
            android:paddingTop="10dp"
            android:text="Title"
            android:textColor="#FFFFFF"
            android:textSize="24sp" />

        <RelativeLayout
            android:id="@+id/channels_sliding_menu"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentRight="true"
            android:clickable="true"
            android:focusable="true">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@drawable/ic_logo" />
        </RelativeLayout>

    </RelativeLayout>

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:isScrollContainer="false">

        <RelativeLayout
            android:id="@+id/layout_list_alerts"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:id="@+id/zero_conversation"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="Empty"
                android:textColor="#000000"
                android:textSize="16sp"
                android:visibility="gone" />

            <RelativeLayout
                android:id="@+id/layout_type_message"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_alignParentBottom="true"
                android:background="#000000"
                android:orientation="horizontal">

                <EditText
                    android:id="@+id/et_type_message"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginBottom="5dp"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="5dp"
                    android:layout_toLeftOf="@+id/layout_send_message"
                    android:background="#FFFFFF"
                    android:hint="Type your message.."
                    android:padding="5dp"
                    android:singleLine="true"
                    android:textColor="#000000"
                    android:textColorHint="#000000"
                    android:textSize="16sp" />

                <Button
                    android:id="@+id/layout_send_message"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerInParent="true"
                    android:layout_marginBottom="10dp"
                    android:layout_marginTop="10dp"
                    android:background="#000000"
                    android:padding="5dp"
                    android:text="Send"
                    android:textColor="#FFFFFF"
                    android:textSize="16sp"
                    android:textStyle="bold" />
            </RelativeLayout>

            <ListView
                android:id="@+id/conversation_list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@id/layout_type_message"
                android:divider="@null"
                android:stackFromBottom="true"
                android:transcriptMode="normal" />
        </RelativeLayout>

        <FrameLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:baselineAligned="false"></FrameLayout>

        <ListView
            android:id="@+id/channels_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:background="#000000"
            android:choiceMode="singleChoice"
            android:divider="@null"
            tools:listtem="@layout/demo_layout" />
    </android.support.v4.widget.DrawerLayout>

</RelativeLayout>
Rahul
  • 510
  • 3
  • 8
  • @Ehsan It is working perfectly at my side, I have checked it. I reused your XML and checked. When Keyboard opens, only bottom panel slides up not Custom Toolbar. Please check my Updated answer. Please check once at your side and let me know. Thanks. – Rahul Feb 11 '16 at 11:58
0

Use Scroll view in Ur Layout or Use the code in the manifest.xml.

<activity android:windowSoftInputMode="adjustPan">
kiran kumar
  • 1,402
  • 17
  • 34
-1

Read this : http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

and use adjustPan

gilgil28
  • 540
  • 5
  • 12
  • Dude I didn't downvote your answer, I dont know why someone did this to your answer. I appreciate you to share your knowledge Thanks. – Ehsan Anjum Feb 12 '16 at 07:07