9

Am using a scrollview inside a relative layout.

I could be able to scroll to end of the page in all mobiles when without keyboard, in some mobiles i could be able to view scroll layout completely when the keyboard is on. ie)- the end of the scrollview above the keyboard.

The problem i have analysed is because of type of keyboard varies in different android devices.

Got some answers to add windowSoftInputMode in activity manifest.

Also added: android:windowSoftInputMode="stateHidden|adjustResize"

But still am getting the same problem. If you have solution or have faced the problem, share your ideas. Thanks for your time.

arnp
  • 3,178
  • 6
  • 26
  • 43
  • It would be really helpful if you could maybe rephrase you question and clearly state your problem. What is the exact behavior that is happening that you do not want? Do you want the scrollview not to get covered by the keyboard and move up when the keyboard comes up? – Daniel Smith Aug 30 '12 at 08:16
  • You need to post your XML code as well of your layout.. – MKJParekh Aug 30 '12 at 08:38
  • @DanielSmith yes. This is what exactly i need what you say. – arnp Aug 30 '12 at 08:55

4 Answers4

3

I came across this question looking into a similar problem. android:windowSoftInputMode="adjustResize" works sometimes, not other times. Why not?

This answer talks about an Android fullscreen theme. Honeycomb (3.1) adjustResize no longer working?

For me the problem was this call here: getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

Setting the flags to fullscreen would prevent proper scrolling when the keyboard appeared.

Community
  • 1
  • 1
jriggs
  • 541
  • 4
  • 16
1

Try this code in onCreate :

getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Eldhose M Babu
  • 14,382
  • 8
  • 39
  • 44
1

These other answers should be solving your problem, so while I am hesitant to suggest the following solution, I will throw it out there just in case you are pressed for time/not doing a project where this is terribly critical: use an OnGlobalLayoutListener.

There is really no way to absolutely know if a softKeyboard has been raised (sadly), but what you could do is adjust your layout to give the keyboard room below your scrollview (i.e. resetting the height to be the current height - the keyboard's height).

There is an answer here that will explain how to do this very well. Again, I am not fully clear on what your problem is because we have not seen code, etc. and this it is hard to diagnose why the other answers are not solving the problem... but if you're really stuck–give it a try :)

Community
  • 1
  • 1
Daniel Smith
  • 8,561
  • 3
  • 35
  • 58
0

You can put configuration over any activity in AdroidManifest.xml, like so...

 <activity android:name=".views.ViewportActivity"
                  **android:windowSoftInputMode="adjustPan|adjustResize"**
                  android:label="@string/app_name"
                  android:configChanges="locale"
                  android:screenOrientation="portrait"
                  android:theme="@android:style/Theme.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
hackp0int
  • 4,052
  • 8
  • 59
  • 95