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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:57:32+00:00 2026-06-03T22:57:32+00:00

I have a problem with programmatically setting the progress drawable of a SeekBar. When

  • 0

I have a problem with programmatically setting the progress drawable of a SeekBar.
When I set it in the .xml file everything is working fine.

<SeekBar
 android:id="@+id/sb"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 .....
 android:progressDrawable="@drawable/seek_bar"/>

set from .xml

But, I have a problem when I try to set it from code like this:

seekBar.setProgressDrawable(getResources().getDrawable(R.drawable.seek_bar));

Background drawable then takes the whole seek bar, and I’m not able to modify the progress at all later on – the thumb moves but the progress drawable still fills whole seekbar. Also, seekbar looses its rounded corners. It seems that progress drawable is on top of the seekbar.

when set in code

I tried the solution provided on android progressBar does not update progress view/drawable, but it doesn’t work for me.

  • 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-03T22:57:33+00:00Added an answer on June 3, 2026 at 10:57 pm

    I solved the problem by using .xml shape as background for my SeekBar.
    The complete SeekBar solution that can be used via setProgressDrawable() method should be like this:

    //seek_bar.xml
    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@android:id/background"
        android:drawable="@drawable/seek_bar_background"/>
    <item android:id="@android:id/progress"
        android:drawable="@drawable/seek_bar_progress" />
    </layer-list>
    
    //seek_bar_background.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <gradient
        android:angle="270"
        android:startColor="#8a8c8f"
        android:endColor="#58595b" />
    
    <corners android:radius="5dip" />
    
    </shape>
    
    //seek_bar_progress.xml
    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@android:id/background"
        android:drawable="@drawable/seek_bar_background"/>
    <item android:id="@android:id/progress">
        <clip android:drawable="@drawable/seek_bar_progress_fill" />
    </item>
    
    </layer-list>
    
    //seek_bar_progress_fill.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <gradient
        android:startColor="#b3d27e"       
        android:endColor="#93c044"
        android:angle="270"
     />
     <corners android:radius="5dip" />  
    
    </shape>
    

    In the code, you can use it like this:

    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.seek_bar));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have problem with autorotate on iphone i set up in all classes -
I have problem with cakephp's Session->write method. If I set a value like $_SESSION['..']
i have problem to correctly bind data to WPF Chart. When i'm setting ItemsSource
The setting is the following: I have a cocoa object in a nib file
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have problem with fancybox. I want to write a function that will run
I have problem with displaying adsense ads in ie7 google adsense adds an iframe
I have problem with Oracle 9.2 and JMS. I created PL/SQL routine to send
I have problem with HTTP headers, they're encoded in ASCII and I want to
i have problem with libhid . i found that there 2 way 4 accessing

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.