Android WebView does not render before I lock/unlock the screen - android

So I have an activity with a WebView with the visibility set to Gone on startup. After a button click, I load the web view with content, set it to Visible and call invalidate() in that order. Yet, it does not render or layout before I turn off the screen (lock the phone) and then back on again. Why not?
It has set height to wrap_content. I'm running Android 4.1 on a HTC one.

Related

Seekbar progress isn't destroyed when activity is rotated

I place a discrete seekbar in my layout. When I run my code in the emulator and rotate the screen, the activity gets destroyed, but for some reason the seekbar progress stays the same. Why does this happen, shouldn't the progress be reset?
Built-in Android View widgets such as TextView, EditText and SeekBar have their state automatically saved and restored when the device configuration changes (in your case, when you rotate the screen), provided they have an id.
That's why your SeekBar's progress is not reset when the screen is rotated.
If you'd like to disable this behavior, you can add android:saveEnabled="false" to your view definition in XML.

Animated Android View with EditText

For the app I'm working on, the signon screen (the main activity) has some animations. Several of the signon related controls (the EditText, an application banner image, the signon button, locked out link, etc) are wrapped into a LinearLayout that starts out centered in parent within a full screen RelativeLayout. When the user taps into the EditText, the animation fades out the banner image as the logon form translates to the top of the screen. When the user dismisses the keyboard the banner image fades in as the form slides back down to the center of the screen.
The two issues are as follows (the first one is the most important since I don't have a workaround for it right now):
When the user is typing into the EditText after it's been animated to the top (it isn't actually animated to the top, the containing LinearLayout is) then you almost never see any text that is typed. It's random... sometimes the hint stays there and sometimes you might see a letter or two. When the keyboard is dismissed and the animation moves everything back to the start, the text is visible. Why?!
When the signon screen is put into the background and then resumed, Android appears to show some cached version of the screen where the controls are in their "focused" state but none of them work. Tapping on the screen where the controls would normally be (in the center) reveals the controls and starts the animation to move them to the top. This happens even if when the screen goes into the background, it's in it's regular state. I "fixed" this by setting a flag when the activity is paused and then checking if the flag is set in resume... if it is then I recreate the activity (by launching a new intent, not by calling recreate since I have to support an older API). It would be awesome if it just didn't show the cached version without me having to jump through these hoops.

Android soft keyboard not panning web view

The original problem I am fighting is more complex but for investigating purposes I have simplified the test case to the following:
Single fullscreen activity
Programmatically created web view that occupies roughly half of the horizontal screen space, 90% of the vertical space and is added to the root view via within the onCreate call:
ViewGroup parent = (ViewGroup) getWindow().getDecorView().getRootView();
parent.addView(myWebView);
web view opens to google.com via:
loadUrl("http://google.com")
AndroidManifest.xml has the property:
"android:windowSoftInputMode="adjustPan"
When clicking on the search box on the google page the keyboard pops up but the web view itself is not shifted up as adjustPan indicates should happen. The main activity also has a native text field that when clicked will shift the entire layout (including web view) up as expected.
The behavior is present on 4.2.2 on both a Nexus 7 and Galaxy Nexus.
So the question is how can I have the windowSoftInputMode property adjustPan be applied correctly to a web view instance so that when the soft keyboard is displayed the entire web view is shifted up by the vertical space taken up by the keyboard.
Before I go down the road of trying to manipulate the layout manually within onMeasure I want to see if there is a consistent / better way to handle this. The browser obviously handles this situation correctly so not sure why the web view is not able to handle this.
One thing to note is that making the web view fullscreen or a separate activity are not possible options due to an existing architecture that I am not able to change.
If we use the full screen without action bar adjustResize will not work. See this thread for details adjustPan not preventing keyboard from covering EditText

Webview moves up when keyboard hides

The issue happens in an application whith a linear layout that divides the screen in two parts, the upper part is a simple View and the lower part is a WebView that loads google.com. The WebView takes the 60% of the space and the View the other 40%. In that scenario I touch the google search bar showing the soft keyboard, inmediately I touch the WebView outside the search bar just at the right of the search button, that hides the soft keyboard but just before this the WebView moves up for an instant and comes back to its initial position as the keyboard dissapears, no idea of why this happens and how to avoid it.
Please see the sample application, to reproduce the issue you can use a WVGA (800×480) simulator, I noticed the issue in a Samsung Galaxy Tab 10.1.
http://www.fileserve.com/file/txC3RV6/WebViewDemo.rar
Any suggestion?
Thanks for your time.
Goyo.
If you put the entire linear view inside the scrollview then the webview wont move up.

How to show the contents hidden by keyboard in the webview

My android application is a webview, and in first page there are 5 editboxes. When i enter some data in editbox the last editbox is hidden by keyboard. So i enclosed webview within a scrollview. But the scrolling is happening only on the first page but not on all the other pages. Is it possible to scroll screen up only if keyboard is hiding some text in webview?
Meanwhile i tried using the window attribute windowSoftInputMode="adjustResize" but still i am getting the same problem. Any Ideas on how to make this working?
-Regards,
Ron..
This could be the consequence of http://code.google.com/p/android/issues/detail?id=5497. Looks like adjustResize should work if you created your layout correctly, but it will not if your app is in fullscreen mode (i.e. the Android status bar is not displayed). If your app runs in fullscreen mode, try the 'normal' mode for a change and see if the webview adjusts its size correctly when the keyboard is displayed.

Categories

Resources