1

I have a listview. Each item (row) of list contains a textView for comment and an editText for replying the comment. Comments are being loaded at runtime.

EditText was remaining hide after keyboard. The solution I searched was to include adjustpan in for specific activity tag in manifest. After that pan was being adjusted for my nexus 5 (5.0), nexus S (4.1.2) and HP touchpad (4.0.3). Felt cool.

But the story was different for Samsung S duos(4.0.4) and Samsung galaxy grand (4.1.2) Even though I tried adjustpan and adjustResize in my manifest ( Individually and together ) devices hides the editText behind keyboard. I noticed a more thing that when I touch the editText on these devices. editText comes perfectly above the keyboard but as soon as I start typing, the screen jumps up n down and finally editText goes behind the keyboard.

I have already tried:

  • android:descendantFocusability="afterDescendants" for editText
  • android:focusable="true" for ediTtext
  • adjustpan and adjustResize in manifest
  • stateHidden and stateVisible are not the solutions as I want keyboard on touch request only.
  • In some articles, they suggested to put views in scrollView, but its not practically possible to put listview in scrollView.

I've spent two days to find out solution. I think this problem is device specific. Is it so? Did any one faced same problem? How can I solve this problem?

Manifest if as follow: (DetailViewActivity is the activity where problem is arising)

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/appTheme" >
    <meta-data
        android:name="android.app.default_searchable"
        android:value="com.examandroid.activities.SearchActivity" />

    <activity
        android:name=".activities.LearnaptActivity"
        android:label="@string/title_activity_learnapt" />
    <activity
        android:name=".activities.SplashActivity"
        android:label="@string/app_name"
        android:theme="@style/SplashTheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".activities.LoginActivity"
        android:label="@string/title_activity_login"
        android:parentActivityName=".activities.SplashActivity"
        android:theme="@style/appTheme" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.examandroid.activities.SplashActivity" />
    </activity>
    <activity
        android:name=".activities.ForgotPasswordActivity"
        android:label="@string/title_activity_forgot_password" />
    <activity
        android:name=".activities.SignupActivity"
        android:configChanges="keyboardHidden|orientation"
        android:label="@string/title_activity_signup"
        android:parentActivityName=".activities.LoginActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.examandroid.activities.LoginActivity" />
    </activity>
    <activity
        android:name=".activities.MainActivity"
        android:label="@string/app_name" />
    <activity
        android:name=".activities.LessonActivity"
        android:label="@string/title_activity_lesson" />
    <activity
        android:name=".activities.SearchActivity"
        android:label="@string/title_activity_search"
        android:parentActivityName=".activities.MainActivity" >
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>

        <meta-data
            android:name="android.app.searchable"
            android:resource="@xml/searchable" />
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.examandroid.activities.MainActivity" />
    </activity>
    <activity
        android:name=".activities.ProfileEditActivity"
        android:label="@string/title_activity_profile_edit"
        android:parentActivityName=".activities.MainActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.examandroid.activities.MainActivity" />
    </activity>
    <activity
        android:name=".activities.DetailViewActivity"
        android:label="@string/title_activity_item_detail_view"
        android:windowSoftInputMode="adjustPan" >
    </activity>
    <activity
        android:name=".activities.ImageFullView"
        android:label="@string/title_activity_image_full_view" >
    </activity>
</application>

HBB20
  • 2,743
  • 1
  • 24
  • 35
  • show your manifest..... – M S Gadag Nov 12 '14 at 10:29
  • Included manifest in question. – HBB20 Nov 12 '14 at 10:40
  • try this.android:configChanges="orientation" – M S Gadag Nov 12 '14 at 10:47
  • Thanks for reply. But this is not solving issue. I am unable to understand why this problem is occurring on some devices, not all. – HBB20 Nov 12 '14 at 10:53
  • have u tried `android:windowSoftInputMode="stateUnspecified|adjustPan"`? – M S Gadag Nov 12 '14 at 11:10
  • and also add `android:isScrollContainer="false"` for your listview. – M S Gadag Nov 12 '14 at 11:32
  • yeah @MSGadag , but those devices are responding same as before. :( – HBB20 Nov 12 '14 at 11:32
  • create **layout-v14 and layout-v16** in res and paste you xml layouts there and try.. im not sure buddy. hope it works for you.. – M S Gadag Nov 12 '14 at 11:41
  • What happens is, by touching editText it comes above keyboard, as soon as I start typing, it goes down. Now if I scroll the screen so that editText is visible again after that it works well. But here one thing I noticed is that screen is not resized (which is resized in my nexus devices). So if the screen is already scrolled up max and edit text is there at bottom, I can not scroll it such that editText become visible to me while typing. – HBB20 Nov 12 '14 at 11:50
  • i think the problem is, u r adding edittext dynamically.. – M S Gadag Nov 12 '14 at 11:54
  • :( . But It works fine on other devices. – HBB20 Nov 12 '14 at 11:57

1 Answers1

0

according to this adjustPan not preventing keyboard from covering EditText u have to desable fullscreen.

try this. onclick edittext.

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
ActivitiesCurrentContentView.requestLayout();

reference:

adjustPan not preventing keyboard from covering EditText

android Exit from full screen mode

Community
  • 1
  • 1
M S Gadag
  • 2,057
  • 1
  • 12
  • 15
  • I also found that pan wont be adjusted if activity is full screen. But my this activity is not full screen activity. Other wise my nexus device also should not adjust pan. – HBB20 Nov 12 '14 at 12:30
  • Anyways I could not find what's ActivitiesCurrentContentView in code ActivitiesCurrentContentView.requestLayout(); – HBB20 Nov 12 '14 at 12:31