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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:45:40+00:00 2026-06-08T17:45:40+00:00

I would like to partially hide a fragment when a new fragment appears. I

  • 0

I would like to partially hide a fragment when a new fragment appears.

I am building on ScienceGuy’s code on GitHub, as referenced on Fragment Animation like Gmail Honeycomb App

I start with three fragments. The left most has a weight of 6, the middle one a weight of 4, and the right most a weight of 4. Setting the weightSum to 10 makes the left and middle fragments appear, and the right most is offscreen. This is what I want.

When the user selects an item in the middle fragment, I would then like to transition the left fragment so that two thirds of it moves off the left side of the screen. Because of the weights, I would effectively have 2, 4 , 4. At this point, the right fragment has moved onto the screen completely.

Using ScienceGuy’s code, I can get the right fragment to appear when the left fragment scrolls off, but the left fragment completely disappears.

I have tried using the following code:

final float middleFragmentWidth = getMiddleFragment().getView().getWidth();
ObjectAnimator animIn = ObjectAnimator.ofFloat(null, "x",
        -middleFragmentWidth/2, 0).setDuration(
        trans.getDuration(LayoutTransition.APPEARING));
trans.setAnimator(LayoutTransition.APPEARING, animIn);


ObjectAnimator animOut = ObjectAnimator.ofFloat(null, "x", -middleFragmentWidth,
        -middleFragmentWidth/2).setDuration(
            trans.getDuration(LayoutTransition.CHANGE_DISAPPEARING));
trans.setAnimator(LayoutTransition.DISAPPEARING, animOut);

I suspect that Android expects that a fragment is completely hidden when one “hides” it. Is there a way to animate fragments so that they are not actually hidden, but partially offscreen?

Alternatively, I could put the three fragments into a HorizontalScrollView, and try animating that. However, I’ve not done that because the middle and right most fragments contain listviews, and using a listview inside a HorizontalScrollView is to be avoided according to the docs.

  • 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-08T17:45:43+00:00Added an answer on June 8, 2026 at 5:45 pm

    I ended up creating a custom view based on LinearLayout which is 150% of the width of the device.

    public class AutoSizingLinearLayout extends LinearLayout {
        private static final String TAG = AutoSizingLinearLayout.class.getSimpleName();
        final int myWidth;
    
    public AutoSizingLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        myWidth = setScaledWidth(context);
    }
    
    public AutoSizingLinearLayout(Context context) {
        super(context);
        myWidth = setScaledWidth(context);
    }
    
    private int setScaledWidth(Context context) {
        if (this.isInEditMode()){
            return 1000;
        } else {
            WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
            return (int) (1.5 * wm.getDefaultDisplay().getWidth());
        }
    }
    
    @Override
    public android.view.ViewGroup.LayoutParams getLayoutParams() {
        android.view.ViewGroup.LayoutParams params = super.getLayoutParams();
        params.width = myWidth;
        return params;
    }
    

    And then I animate it like this.

                        ObjectAnimator a = ObjectAnimator.ofFloat(linearView,"translationX", -scrollamount).setDuration(900);
                    a.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im relatively new to ROR, and would like some help with the following code.
Would like to know the c# code to actually retrieve the IP type: Static
Would like to know how to hide an div after a set of css3
I am implementing a search where I would like to partially match an entity's
I would like to use a CATextLayer to display some partially bolded text in
I would like to configure my bash shell to expand partially entered tree structure
I would like to partially collapse a DataFrame /matrix and keep the structure intact
I would like to write a ItemsControl derived custom control. This is partially from
I have some code in the form of a string and would like to
I would like to implement a scripting language to assist in partially automating certain

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.