Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8021091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:52:27+00:00 2026-06-04T21:52:27+00:00

I have a layout that has a ViewPager inside of a custom ScrollView and

  • 0

I have a layout that has a ViewPager inside of a custom ScrollView and the ViewPager won’t scroll vertically. The custom ScrollView is used to fix the dreaded tab swiping with a ScrollView.

Yes, there is enough content for it to scroll and I’ve tried with and without the bottom buttons.

I’m using the ActionBar that has 3 tabs and the current code allows swiping left / right just fine.

My goal is to have the bottom bar for a couple action items such as save and cancel and the part between the ActionBar and the buttons at the bottom be the ViewPager that will scroll vertically.

I’ve tried too many combinations and am now sending this love letter to you. Any ideas? Any help is appreciated and feel free to ask for additional details if needed.

main.xml

<?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" >

    <LinearLayout
        android:id="@+id/footer"
        style="@android:style/Holo.ButtonBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/saveButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Save" />

        <Button
            android:id="@+id/cancelButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Cancel" />
    </LinearLayout>

    <com.blah.hootiehoo.ViewPagerCompatScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/footer"
        android:fillViewport="true" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:scrollbarAlwaysDrawVerticalTrack="true"
            android:scrollbars="vertical" >

            <android.support.v4.view.ViewPager
                android:id="@+id/pager"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:scrollbarAlwaysDrawVerticalTrack="true"
                android:scrollbars="vertical" >
            </android.support.v4.view.ViewPager>
        </LinearLayout>
    </com.blah.hootiehoo.ViewPagerCompatScrollView>

</RelativeLayout>

MainActivity.java

ViewPager mViewPager;
TabsAdapter mTabsAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    mViewPager = (ViewPager)findViewById(R.id.pager);

    // setup action bar for tabs
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);   

    mTabsAdapter = new TabsAdapter(this, mViewPager);

    Tab tab = actionBar.newTab();
    // tab setup
    mTabsAdapter.addTab(/*** stuff ***/);

    // add 2 more tabs, etc
}

ViewPagerCompatScrollView.java Got from here, at bottom

public class ViewPagerCompatScrollView extends ScrollView {
    private float xDistance, yDistance, lastX, lastY;

    public ViewPagerCompatScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                xDistance = yDistance = 0f;
                lastX = ev.getX();
                lastY = ev.getY();
                break;
            case MotionEvent.ACTION_MOVE:
                final float curX = ev.getX();
                final float curY = ev.getY();
                xDistance += Math.abs(curX - lastX);
                yDistance += Math.abs(curY - lastY);
                lastX = curX;
                lastY = curY;
                if(xDistance > yDistance)
                    return false;
        }

        return super.onInterceptTouchEvent(ev);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:52:29+00:00Added an answer on June 4, 2026 at 9:52 pm

    As per earlier comment:

    Is it an option to swap the ScrollView and ViewPager around? From experience I know that a ScrollView inside a ViewPager works without any problems. So basically instead of wrapping the ViewPager by a ScrollView, give every ‘page’ a ScrollView as root.

    Glad to hear that worked for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView that uses a custom layout that has 5 child View
I'm trying to have a grid that has items that have a custom layout/feel.
If you have a layout that has a bunch of views that won't be
Hy, I have a layout in the views/layout that has 2 cols and then
I have been able to design my layout so that it has 2 columns
I have an ExtJS Viewport with a container that has the border layout and
I need to have a layout that has a view above a set of
Have a liquid layout that has fixed width for left side and elastic right
If you have a layout that has in a menu which gets its menu
I have a linear layout that has an image in it I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.