0

I have an EditText and a button capsuled in a LinearLayout but on typing on the EditText, the keyboard on android hides the layout in spite of specifying

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

and

       <activity
        android:name=".postNavigator"
        android:label="@string/title_activity_post_navigator"

        android:windowSoftInputMode="adjustPan|adjustResize">

    </activity>

Keyboard hides the EditText

my xml code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.dailyspring.rejo.cpray.postNavigator">

<!--<ImageView-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="fill_parent"-->
<!--android:scaleType="centerCrop"-->
<!--android:src="@drawable/back_blur" />-->

<LinearLayout android:orientation="vertical"
    android:layout_width="match_parent"
    android:weightSum="2"
    android:layout_height="match_parent">



    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="15sp"
        android:layout_marginRight="15sp"
        android:layout_marginTop="15sp"
        android:layout_weight="1"
        android:orientation="vertical"
        android:weightSum="1">

        <com.github.leonardoxh.customfont.FontText
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="10sp"
            android:text="Post Title"
            android:textAlignment="center"

            android:textSize="25dp"
            app:font="Roboto-Thin" />
        <com.github.leonardoxh.customfont.FontText
            android:id="@+id/authorName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="10sp"
            android:text="Author"
            android:textAlignment="center"
            android:textSize="15dp"
            app:font="Roboto-Thin" />

        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            >

            <TextView
                android:id="@+id/txtDesc"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"

                android:text="DescriptionDescription Description Description DescriptionDescription Description Description Description Description Descriptionescription sDescripti Description Description Description Description Description Description Descriptionescription sDescripti Description Description Description Description Description Description Description" />
        </ScrollView>


    </LinearLayout>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5">
            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
                <ProgressBar
                    android:layout_width="fill_parent"
                    android:layout_gravity="top"
                    android:layout_height="55dp"
                    android:id="@+id/loadingProgressBar"/>
                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:orientation="vertical"
                    android:layout_marginLeft="15sp"
                    android:layout_marginRight="15sp"
                    android:layout_marginTop="15sp">

                    <com.github.leonardoxh.customfont.FontText
                        android:id="@+id/commentTitle"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="left"
                        android:layout_marginBottom="10sp"
                        android:text="Comments"
                        android:textAlignment="center"
                        android:textSize="15dp"
                        app:font="Roboto-Thin" />


                    <ListView
                        android:id="@+id/listcomments"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:divider="@null"
                        android:dividerHeight="0dp"
                        android:paddingBottom="10dp"
                        android:fadeScrollbars="false"
                        android:listSelector="@drawable/list_selector"
                        android:background="@drawable/rounded_corner_nobg"
                        android:transcriptMode="alwaysScroll"
                        android:stackFromBottom="true"/>
                </LinearLayout>


            </RelativeLayout>
        </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:layout_marginBottom="15sp"
                android:layout_marginLeft="15sp"
                android:layout_marginRight="15sp"
                android:layout_marginTop="15sp"
                android:orientation="horizontal">

                <EditText
                    android:id="@+id/commentText"

                    android:layout_width="fill_parent"
                    android:layout_height="50dp"
                    android:paddingLeft="10dp"
                    android:background="@drawable/rounded_corner"
                    android:imeOptions="flagNoFullscreen"
                    android:hint="  add comment"
                    android:layout_weight="0.5"/>
                <at.markushi.ui.CircleButton

                    android:layout_width="53dp"
                    android:layout_height="53dp"
                    android:id="@+id/pickImage"
                    android:src="@drawable/ic_send_white_48dp"
                    app:cb_color="#99CC00"
                    app:cb_pressedRingWidth="5dip" />

            </LinearLayout>
    </LinearLayout>
</LinearLayout>

I've tried adjusting the android:layout_weight and adjusting the margins and padding but nothing helps. How can i solve this ?

Rejo Chandran
  • 599
  • 4
  • 22

2 Answers2

0

android:windowSoftInputMode couldn't be something OR something, you should set here only one value. In your case I think you need adjustPan.

Btw, why are you using all that weight? It some mess in your layout. Your UI could be implemented just with simple vertically oriented LinearLayout. Also TextView inside ScrollView? Use maxLines param.

Divers
  • 9,531
  • 7
  • 45
  • 88
  • @RejoChandran Complitly relayout your UI, as I suggested and everything would be ok. – Divers May 19 '15 at 16:52
  • I guess the Layouts need to be worked again; Anyways android:windowSoftInputMode="adjustResize" should push all the elements off the screen regardless of the alignment... – Rejo Chandran May 19 '15 at 17:01
-1

Use windowSoftInputMode, like this:

android:windowSoftInputMode="adjustPan"
Jonas Czech
  • 12,018
  • 6
  • 44
  • 65
Deepanshu Gandhi
  • 490
  • 3
  • 10