Narendra Pal
Narendra Pal

Reputation: 6604

Edit Text is not showing while opening the soft keyboard in android

I have created an activity. It's working fine. But when i try to take input through the edit text. I am selecting the edit text, then the edit text gets hidden by the soft keyboard.

I have tried by giving the android:windowSoftInputMode="adjustPan" and android:windowSoftInputMode="adjustResize" permission, but its not getting solved. please help me to resolve this issue guys.

Here is my screen when the activity is shown.

initially looks like this

And it shown like this when the edit text is selected.

enter image description here

You can see in the above image,the edit text is gets hidden, thats why i am unable to enter the text inside that. please help me resolve this.

This is my layout.xml

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/textViewOSoutletName"
        style="@style/HeadingTheme"
        android:drawableRight="@drawable/transaction"
        android:paddingBottom="0dp"
        android:paddingRight="10dp"
        android:text="@string/outletname" >
    </TextView>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:background="@color/black_dark" >
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="1" >

    <TextView
        android:id="@+id/textViewOSBrand"
        style="@style/Head_Text"
        android:layout_weight="0.2"
        android:text="@string/brand"
        android:textSize="25dp" />

    <Spinner
        android:id="@+id/spinnerOSBrandName"
        style="@style/Style_Spinner"
        android:layout_height="50dp"
        android:layout_weight="0.8" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:layout_marginTop="2dp"
    android:background="@color/black_dark" >
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="1" >

    <TextView
        android:id="@+id/textViewOScategory"
        style="@style/Head_Text"
        android:layout_weight="0.2"
        android:text="@string/category"
        android:textSize="25dp" />

    <Spinner
        android:id="@+id/spinnerOScategoryName"
        style="@style/Style_Spinner"
        android:layout_height="50dp"
        android:layout_weight="0.8" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:layout_marginTop="2dp"
    android:background="@color/black_dark" >
</LinearLayout>

<TextView
    android:id="@+id/textViewOSProductNameHeading"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:gravity="center"
    android:singleLine="true"
    android:text="@string/product_name"
    android:textColor="@color/blue"
    android:textSize="25dp" />
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:orientation="vertical"
    android:layout_weight="1.0">
 <HorizontalScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:fadingEdge="none"
    android:fillViewport="true"
    android:scrollbars="none" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="@color/grey_default"
        android:weightSum="1" >

        <TextView
            android:id="@+id/textViewOSProductName"
            style="@style/ListViewHeaderThemeLarge"
            android:layout_width="0dp"
            android:layout_weight="0.5"                
            android:text="@string/product_name" />

        <ImageView
            android:id="@+id/imageViewseparator1"
            style="@style/ListViewHeaderSeperator" />

        <TextView
            android:id="@+id/textViewOSQuantity"
            style="@style/ListViewHeaderThemeLarge"
            android:layout_width="0dp"
            android:layout_weight="0.25"
            android:gravity="center"
            android:text="@string/qty" />

        <ImageView
            android:id="@+id/imageViewseparator2"
            style="@style/ListViewHeaderSeperator" />

        <TextView
            android:id="@+id/textViewOSPrice"
            style="@style/ListViewHeaderThemeLarge"
            android:layout_width="0dp"
            android:layout_weight="0.25"
            android:gravity="center"
            android:text="@string/rp" />           
    </LinearLayout>

</HorizontalScrollView>
 <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
         <ListView
            android:id="@+id/listViewOS"
            style="@style/ListViewTheme"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </ListView>
    </LinearLayout>
    </LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/footer_background_drawable"
    android:gravity="center"
    android:orientation="vertical" >

    <View
        style="@style/horizontalImg"
        android:background="@color/black_dark" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:orientation="horizontal"
        android:weightSum="1" >

        <Button
            android:id="@+id/buttonOSBack"
            style="@style/styleNormalButtonLargeLand"
            android:drawableLeft="@drawable/left"
            android:text="@string/back" >
        </Button>

        <Button
            android:id="@+id/buttonOSSubmit"
            style="@style/styleNormalButtonLargeLand"
            android:drawableRight="@drawable/discount1"
            android:text="@string/discount" >
        </Button>
    </LinearLayout>


</LinearLayout>

And this is my layout for creating the list elements.

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

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1"
        android:background="@drawable/list_selector" >

        <TextView
            android:id="@+id/textViewOSLProductName"
            style="@style/ListViewTextViewLarge"
            android:layout_width="0dp"
            android:layout_weight="0.5"
            android:ellipsize="end"
            android:gravity="left"
            android:paddingLeft="3dp"
            android:singleLine="true"
            android:text="@string/product_name"
            android:textColor="@drawable/text_selector" />

        <ImageView
            android:id="@+id/imageViewselparator1"
            style="@style/ListViewTextSeperatorForAll" />

        <EditText
            android:id="@+id/editTextOSLQuantity"
            style="@style/ListViewTextViewLarge"
            android:layout_width="0dp"
            android:layout_weight="0.25"
            android:background="#FBFCFE"
            android:gravity="center"
            android:inputType="number"
            android:maxLength="5"
            android:text="qty"
            android:textStyle="bold"
            android:textColor="@color/black_dark" />
        <!-- android:background="#404040" -->

        <ImageView
            android:id="@+id/imageViewselparator2"
            style="@style/ListViewTextSeperatorForAll" />

        <TextView
            android:id="@+id/textViewOSLPrice"
            style="@style/ListViewTextViewLarge"
            android:layout_width="0dp"
            android:layout_weight="0.25"
            android:gravity="center"
            android:maxLength="8"
            android:text="rp"
            android:textColor="@drawable/text_selector" />
    </LinearLayout>

</LinearLayout>

Thanks in advance.

Upvotes: 2

Views: 3332

Answers (3)

user1881979
user1881979

Reputation:

Inside your Android manifest file, you had to set this tag in your desired activity

android:windowSoftInputMode="adjustPan"

And Let me know if it works

Upvotes: 5

Usman Kurd
Usman Kurd

Reputation: 7023

Try ScrollView add android:layout_gravity="center"

Upvotes: 2

RufusInZen
RufusInZen

Reputation: 2189

This is an Android issue (see link below) and happens in fullscreen, i.e. when there is no statusbar. Try your app in non-fullscreen.

Android issue: http://code.google.com/p/android/issues/detail?id=10510

Edit: Fullscreen flags - you should remove these if you have them.

requestWindowFeature(Window.FEATURE_NO_TITLE); // removes title
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // removes statusbar

Upvotes: 0

Related Questions