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 8791007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:47:01+00:00 2026-06-13T22:47:01+00:00

I understand that in order to swipe between activities I need to use the

  • 0

I understand that in order to swipe between activities I need to use the FragmentPageAdapter as in the answer to this this question.

However, I’m trying to put a frame around the Fragments that does not move. Something like a picture frame that stays in place around the edges of the screen and when you swipe, the frame stays in place, while the Fragments slide between each other. Basically, a masking effect. How can I implement this?

In my FragmentActivity’s FragmentPagerAdapter I have a different Fragment that I call compared to the example shown which is a list fragment (ArrayListFragment). I use a a generic fragment as so:

public static class TestFragment extends Fragment{
        /**
         * Create a new instance of DetailsFragment, initialized to
         * show the text at 'index'.
         */
        public static TestFragment newInstance(int index) {
            TestFragment f = new TestFragment();

            // Supply index input as an argument.
            Bundle args = new Bundle();
            args.putInt("index", index);
            f.setArguments(args);

            return f;
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.mytext, container, false);
            return v;
        }
    }

The mytext layout is quite simple:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:text="woohoo"
        android:gravity="center"></TextView>

</LinearLayout>
  • 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-13T22:47:02+00:00Added an answer on June 13, 2026 at 10:47 pm

    One easy way to implement that frame is to put the ViewPager in a FrameLayout or a RelativeLayout with a custom View on top of it:

    <FrameLayout>
        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    
        <com.luksprog.ViewPagerOverlayFrame
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
    

    In that custom View‘s onDraw method you’ll draw the frame you want. The code below will draw a unswipeable red frame near the edges of the ViewPager:

    public class ViewPagerOverlayFrame extends View {
    
        private Paint mPaint;   
    
        public ViewPagerOverlayFrame(Context context) {
            super(context);
            mPaint = new Paint();
            mPaint.setColor(Color.RED); 
                mPaint.setStrokeWidth(60.0f);       
        }
    
        public ViewPagerOverlayFrame(Context context, AttributeSet attrs) {
            super(context, attrs);
            mPaint = new Paint();
            mPaint.setColor(Color.RED);
            mPaint.setStrokeWidth(60.0f);       
        }
    
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawLine(0, 0, getMeasuredWidth(), 0, mPaint);
            canvas.drawLine(getMeasuredWidth(), 0, getMeasuredWidth(),
                    getMeasuredHeight(), mPaint);
            canvas.drawLine(getMeasuredWidth(), getMeasuredHeight(), 0,
                    getMeasuredHeight(), mPaint);
            canvas.drawLine(0, getMeasuredHeight(), 0, 0, mPaint);
        }
    
    }
    

    You may want to add some padding to the ViewPager so its content doesn’t get clipped by the frame.

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

Sidebar

Related Questions

I understand that this question may be subjective, this is why I need an
I understand that I need to use LoadLibrary(). But what other steps do I
I totally understand that in order to learn javascript I need to know how
I understand that in order to sum array elements in Ruby one can use
I understand that Haskell's filter is a high order function (meaning a function that
Some projects are so big that in order to understand for example a function
I understood that in order to use cookies inside of phonegap native app there
I understand that in order to do a subtraction you should do a 2's
Iam trying to resize the facebook profile picture to large. I understand that in
Guys before you start down voting me please read this question and please understand

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.