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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:47:32+00:00 2026-06-16T00:47:32+00:00

I have SeekBar s in an application which operate as expected and return values

  • 0

I have SeekBars in an application which operate as expected and return values that I expect. However, on Android 2.x they display oddly.

enter image description here

I’ve looked for other similar things such as Android Drawable setLevel(); not filling SeekBar appropriately, but that is for a custom drawable. Otherwise I’m having trouble coming up with search terms for this issue to get anywhere.

In this case, all I’m doing is

SeekBar seekBar = (SeekBar)dialogLayout.findViewById(R.id.my_seek);
seekBar.setProgress(5);
seekBar.setMax(20);

If I move the slider, it properly fills the SeekBar the moment it’s moved.

Any idea on what is going on?

  • 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-16T00:47:34+00:00Added an answer on June 16, 2026 at 12:47 am

    After posting this, I realized the problem was the order of the method calls.

    Incorrect

    SeekBar seekBar = (SeekBar)dialogLayout.findViewById(R.id.my_seek);
    seekBar.setProgress(5);
    seekBar.setMax(20);
    

    Correct

    SeekBar seekBar = (SeekBar)dialogLayout.findViewById(R.id.my_seek);
    seekBar.setMax(20);
    seekBar.setProgress(5);
    

    From what I gather if you first call setProgress(5) in my case, the system will set the drawable to display the progress as 5% since it is 5 / 100 and 100 is the default maximum.

    Then if you call setMax(20), the value of 5 is still valid but the drawable is no longer valid and is not recalculated to display as 25% (5 / 20) of the bar.

    Doing setMax(20) first will compel the drawable to be calculated correctly once you use setProgress(5).

    In case it’s of use to anyone, I tested this on Android 2.1, 2.2, 4.1 and 4.2.

    • Android 2.1 and 2.2 have this bug, the order matters
    • Android 4.1 and 4.2 do not have this bug, the order doesn’t matter

    Essentially to remain backwards compatible, always do setMax(int) first and then setProgress(int).

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

Sidebar

Related Questions

In my application I have a Seekbar that is shown in a dialog. Now
So in my application, I have a seekbar that allows the user to set
I'm playing video via MediPlayer in my android application and have SeekBar displayed. Now
What I have is a seekbar which is controlled by buttons rather than a
So I have a Player view with seekbar and play/pause/rewind, etc. buttons, which are
I have a ClassCastException being thrown saying that I'm trying to cast a SeekBar
Possible Duplicate: Android: Set interval in SeekBar I have a seekbar with max value
I have a seekbar in my app, which shows the level of age in
I have a SeekBar in my application, and I want it to behave so
I have a an activity which has a custom layout, with SeekBar and a

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.