1

I have a application 50% native 50% is webview. I have only 1 input in webview but this is the problem, when keyboard open not scrolling webview.

enter image description here enter image description here My webview code:

    WebView webview = (WebView) findViewById(R.id.webview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setAllowFileAccess(true);
    webview.setVerticalScrollBarEnabled(true);
    webview.setDownloadListener(this);
    webview.requestFocus(View.FOCUS_DOWN);
    webview.requestFocus(View.FOCUS_UP);
    webview.loadUrl("WEBVIEW URL");

Webview layout:

            <android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />

<RelativeLayout
    android:id="@id/activity_main"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF">

    <RelativeLayout
        android:id="@id/header"
        android:layout_width="fill_parent"
        android:layout_height="260.0dip"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/header" />

    <RelativeLayout
        android:id="@id/logo_main"
        android:layout_width="170.0dip"
        android:layout_height="170.0dip"
        android:layout_above="@+id/container"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="28dp"
        android:background="@drawable/logo" />

    <RelativeLayout
        android:id="@id/container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/header">

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="100.0dp"
            android:layout_below="@+id/insert_link"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_above="@+id/adView" />

        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            app:adSize="SMART_BANNER"
            app:adUnitId="@string/admob_banner_id" />

        <TextView
            android:id="@+id/downloader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="18dp"
            android:textSize="27dp" />

        <TextView
            android:id="@+id/insert_link"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/insert_link"
            android:textSize="17dp"
            android:layout_below="@+id/downloader"
            android:layout_centerHorizontal="true" />
    </RelativeLayout>

</RelativeLayout>

I tired this solutions but still same: WebView doesn't scroll when keyboard opened

WebView textarea doesn't pop up the keyboard

What can I do about it?

Community
  • 1
  • 1
Onur YIlmaz
  • 51
  • 2
  • 9

2 Answers2

0

You have to resize your layout when keyboard open, so it would be scrollable in other area

set programmatically

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

and change height of WebView

android:layout_height="100.0dp"

to

android:layout_height="match_parent"

Kishore Jethava
  • 6,666
  • 5
  • 35
  • 51
0
android:windowSoftInputMode="stateVisible|adjustResize" 

add this line in your activity manifest file

user1517638
  • 972
  • 1
  • 10
  • 16