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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:20:15+00:00 2026-06-05T13:20:15+00:00

Given: Two vertically placed elements on the screen (ViewPager and Fragment) Action in the

  • 0

Given:

  1. Two vertically placed elements on the screen (ViewPager and Fragment)
  2. Action in the first currently selected fragment (ViewFlipper) toggles between text-based and WebView-based view in the top fragment and hides/shows bottom fragment.

Observed:

  1. Hiding the bottom fragment leaves an empty space where the bottom fragment is located.

I tried both Relative and LinearLayout (with top fragment set to weight=1) but both have no effect after bottom fragment is removed I still have empty space on the bottom

Here’s top level layout file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="fill_parent"
    android:layout_height="0dip" android:layout_weight="1"/>

<!-- This gets replaced with appropriate fragment at run time -->
<LinearLayout
    android:id="@+id/scrollFragmentPlaceholder"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:minHeight="110dip" />
</LinearLayout>

Here’s code that toggles the fragment

    Fragment scroll = getSupportFragmentManager().findFragmentById(R.id.scrollFragment);
    if (scroll.isHidden() == isWebView)
        return; // already handled, do nothing
    FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
    if (scroll != null && scroll.isAdded()) {
        if (isWebView) {
            tr.hide(scroll);
        } else
            tr.show(scroll);
    }
    tr.commit();

And here’s how it looks:
Bottom fragment is hidden

  • 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-05T13:20:17+00:00Added an answer on June 5, 2026 at 1:20 pm

    A month later I figured out how to do it. Turns out that simply hiding the fragment is not enough, basically I need to hide/show the shell containing the fragment. It is still the LinearLayout that was originally defined in XML. In fact, it’s sufficient to set visibility on that original layout to show/hide the fragment. So the code from the question now looks like this:

    public void onJobViewToggled(final boolean isWebView) {
        if (isFinishing())
            return;
        final Fragment scroll = getSupportFragmentManager().findFragmentById(R.id.scrollFragment);
        if (scroll.isHidden() == isWebView)
            return; // already handled, do nothing
        final FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
        if (scroll != null && scroll.isAdded()) {
            if (isWebView) {
                tr.hide(scroll);
                // shell is the original placeholder
                shell.setVisibility(View.GONE);
            } else {
                tr.show(scroll);
                shell.setVisibility(View.VISIBLE);
            }
        }
        tr.commit();
    }
    

    Note that you still want to show/hide the fragment for this to work

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

Sidebar

Related Questions

Given two entities: Parent, Child. Table per type inheritance what does it do when:
Given two arrays: double[] a = new double[]{1.0, 2.0, 3.0}; bool[] b = new
Given two datetimes ( start_date and end_date ), I'd like to generate a list
Given two strings text1 and text2 : public SOMEUSABLERETURNTYPE Compare(string text1, string text2) {
Given two identical boost::variant instances a and b , the expression ( a ==
Given: two images of the same subject matter; the images have the same resolution,
Given two methods on the same class in Java : public void doSomething( Person
Given two dates, what is the best method to calculate the number of days
Given two stream-oriented I/O objects in Asio , what is the simplest way to
This is a two part question - first I need to get every element

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.