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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:46:29+00:00 2026-06-10T18:46:29+00:00

I have a LinearLayout that will have a cancel button and a progress bar,

  • 0

I have a LinearLayout that will have a cancel button and a progress bar, where the progress bar is 70% and the cancel button is 30%, like so:

<LinearLayout android:orientation="horizontal"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
  >

 <ProgressBar
     android:id="@+id/uploadProgressBar"
     style="?android:attr/progressBarStyleHorizontal"
     android:layout_width="0dp"
     android:layout_weight=".7"
     android:layout_height="wrap_content"
     android:layout_gravity="center_vertical"
     />
 <Button
     android:id="@+id/uploadCancelButton"
     style="@style/TitleBarButton"
     android:layout_width="0dp"
     android:layout_weight=".3"
     android:layout_height="wrap_content"
     android:text="@string/cancel_btn"
     android:layout_gravity="center_vertical"

      />

 </LinearLayout>

This works fine, however I realized that actually I either want to show the progress bar or a text view, where the text view could be a small status message (if say the upload failed).

I tried putting a TextView in the the above LinearLayout and having its visibility set to “gone” by default and with the weight set the same as the progress bar. In the code I would only set either the progress bar to visible or the text view, and the other I would set to gone. However the android system appeared to contribute the invisible items weight to the total. I even tried using android:weightSum=”1.0″ in the LinearLayout xml attributes but that then my button was no longer visible as even though the text was gone, it took space.

  • 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-10T18:46:30+00:00Added an answer on June 10, 2026 at 6:46 pm

    ViewFlipper is what you are looking for.

    It is very simple to use. You put the views you want to toggle inside the ViewFlipper exactly the same way like you would place them within a Layout inside XML. Then from code you call setDisplayedChild() on the ViewFlipper object containing your views. The parameter of this method is the index of the view that you want to be shown.

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

Sidebar

Related Questions

I want that button(child) will have 25% of full width of horizontal LinearLayout (its
I'm writing my first Android application and I have one activity that I'd like
i have coded an android application that will update GPS coordinates to the exif
lets assume i have a LinearLayout , horizontal that contains a TextView and afterward
i need to create a login screen in android that will look like this.
Intro: I have a LinearLayout, which contains two sub LinearLayouts, like so: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a LinearLayout that contains a TextView, and always will. There will also
I have a code that should get a LinearLayout (with more LinearLayout's inside), and
There is one image on LinearLayout. I have to move that image in any
I have a Linear Layout that has a Button and a TextView on it.

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.