I've got a very basic webview app, and this is the layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
In the manifest I have:
android:windowSoftInputMode="stateVisible|adjustResize"
In the page I load, there is an input at the bottom of the page. When I click it, the keyboard shows, but obscures it. It's not a case of the view shrinking but not scrolling, as I can't scroll the webview to show the input with the keyboard visible. What am I doing wrong?
It's a bug with WebViews in fullscreen apps. More information in this other answer, but I fixed it by making my app non-fullscreen.
Related
I am using a Relative layout as root view and i have a view in bottom. When i am opening keyboard my View goes up and then i use
<activity
android:windowSoftInputMode="adjustPan">
</activity>
View that need to be in bottom
After doing this my View is not showing up but Still my content is not scrolling up, it's behind the screen. I want to scroll my content till the bottom
How to achieve it? Please help me.
Scroll the view after keyboard open
try this
android:windowSoftInputMode="adjustResize"
And if you are using full screen activity then nothing will work.
Try including your layout inside a ScrollView, it will allow you to scroll when keyboard is open.
Do like this...(Tested)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center">
//define you bottom view here
</RelativeLayout>
<ScrollView
android:id="#+id/scrollableContents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="false"
android:layout_above="#id/footer">
//Rest of the view except bottom view
</ScrollView>
</RelativeLayout>
And in manifest define
android:windowSoftInputMode="stateVisible|adjustPan"
This code is working great for me.
i want the whole layout move up to show while popping the soft keyboard, but the button on the bottom of the view cannot be seen.
the AndroidManifest.xml:
<activity
android:name="cn.duckr.android.plan.PlanConfirmPaymentActivity"
android:windowSoftInputMode="adjustPan"
style="#style/base_activity_style"
android:theme="#style/confirm_payment_anim_theme" />
To ensure that the system resizes your layout to the available space—which ensures that all of your layout content is accessible (even though it probably requires scrolling)—use "adjustResize".
link
android:windowSoftInputMode="adjustResize"
You can put whole layout except the particular button in a ScrollView to achieve this.
like this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollView5"
android:fillViewport="true">
//put your contents here..
</ScrollView>
<ImageButton
android:id="#+id/ibSample"
android:layout_width="50dp"
android:layout_height="50dp"
android:adjustViewBounds="true"/>
</RelativeLayout>
Before I implemented a linear layout with button and webview, my standalone webview worked fine. I added the following and now only the button shows up:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<ImageButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/back_nav"
/>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
I just want a button that spans the top, with a webview underneath it that fills the rest of the view.
What am I doing wrong?
Your orientation is set to horizontal, and the button is set to "fill_parent", so that means the webview will come to the right of the button, which fills the entire screen, making the webview appear off the screen.
To fix this, set orientation of your LinearLayout to "vertical".
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:fadeScrollbars="false" >
<Scrollview ...
i want to show the scrollbar always (android:fadeScrollbars="false")! I have also EditTexts on my screen, too. That is why I put (android:focusableInTouchMode="true" and android:focusable="true"). If i put this last 2 codes my scrollbar going to fade out, why? Do you have a solution?
please this in place of that one.
Achieved the desired result here and added in manifest for each activity
android:windowSoftInputMode="stateHidden"
I have an Android application that is a TabHost with a WebView. I use it to load a specific html file that has a text field in its bottom part.
When I touch the html textfield, the soft keyboard pops up, and hides the textfield, so that I cannot see what I have typed.
Here is the layout:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TabWidget
android:focusableInTouchMode="false"
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="63dp" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
I have tried to configure the AndroidManifest.xml file with android:windowSoftInputMode="adjustResize" with no success. I have also tried replacing the FrameLayout in my layout with ScollView, but that caused my webview to increase in size indefinitely when the application is running.. this may be due to some javascript I have running on the page.
I have noticed that the android's web browser has a nifty behavior - in a web page, after the soft keyboard pops up, the web page scrolls smoothly so that the focusable textfield is visible to the user. How can I have this kind of behavior in my application?
I was getting crazy nothing works android:windowSoftInputMode="adjustResize" may help but be sure to have your app not in full screen.
Removing full screen for my app solved the problem with the layout resize with softkeyboard.
<item name="android:windowFullscreen">false</item>
I found a solution for this issue. (about a week after I posted the question; I only got to answering in stackoverflow today...)
I had pieces in my code that changed the WebView's height (to have room for a TabBar). Turns out that when you invoke setLayoutParams on a WebView, it will no longer change its height even if you have android:windowSoftInputMode="adjustResize" set.
I circumvented the need to change the WebView's height by adding the TabBar to the main.xml layout file, with an initial size of 0. When I increase the TabBar's size, the WebView's size decreases automatically, and it preserves the android:windowSoftInputMode="adjustResize" behavior.