venky
venky

Reputation: 195

Android scrolling issue webview inside scrollview with viewpager

I have a viewpager which contains a layout with scrollview as parent and webview as child.I had never faced a problem with portrait mode however in landscape mode it's acting very strange.

The screen is taking portrait height(which i'm assuming) in landscape too. So the scrollview is getting activated when scrolling down.

If I block the touch by putting requestDisallowInterceptTouchEvent(true); but if I do that i'm unable to move to next page.

I gave the following in configChanges

android:configChanges="keyboardHidden|orientation|screenSize"

Here's my main xml code

<?xml version="1.0" encoding="utf-8"?><ScrollView
android:id="@+id/nestedScrollView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fillViewport="true">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/topMostLayout">
    <RelativeLayout
        android:id="@+id/topbarlayout"
        android:layout_width="match_parent"
        android:layout_height="43dp"
        android:background="@android:color/white">
    </RelativeLayout>



<View
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="@android:color/darker_gray"
        android:layout_marginBottom="4dp" />
    <com.mango.expert.utils.FullCard_ShadowLayout
        android:id="@+id/activity_shadow_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:sl_cornerRadius="7dp"
        app:sl_shadowColor="@color/shadow">
        <FrameLayout
            android:id="@+id/dummyLayoutForViewPager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
<LinearLayout
                android:id="@+id/dummyLinearLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_margin="2dp"
                android:background="@drawable/for_full_card_bg" >
            </LinearLayout>
        </FrameLayout>
    </com.mango.expert.utls.FullCard_ShadowLayout>

<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">

</android.support.v4.view.ViewPager>   

Some tags are missing, i'm finding difficulty in pasting xml here.xml is totally fine. Any help would be really great.Forgot to mention that webview is in Fragment and Scrollview is in main layout

Upvotes: 0

Views: 2889

Answers (2)

Suhayl SH
Suhayl SH

Reputation: 1223

Enable NestedScrolling on parent layout:

parent.setNestedScrollingEnabled(true);

or wrap your entire layout inside NestedScrollView:

<android.support.v4.widget.NestedScrollView
        android:id="@+id/nScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <FrameLayout ...>
           <ViewPager ... />
        </FrameLayout >
    </android.support.v4.widget.NestedScrollView>

Upvotes: 0

bharat7777
bharat7777

Reputation: 323

You don't need to implement ScrollView for WebView. It's already have that feature it self.

Upvotes: 1

Related Questions