2

How to change the default color in Android 5.1 and 6. How to Make Layout look like API 19 in API 22,23?

I have been using this color to show progress bar color:

 <color name="colorAccent">#EFAD04</color>

It's working in kitkat and lower versions but not in lollipop and Marshmallow

here's the progressBar.java

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.progress_bar);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP|| android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
    {
    progressBar = (ProgressBar) findViewById(R.id.progress_Launch);

        progressBar.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(Progressbar.this, R.color.colorAccent), PorterDuff.Mode.SRC_IN);

    }else {
     progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor( R.color.colorAccent), PorterDuff.Mode.SRC_IN);
    }
    progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);

    handler = new Handler();
    Thread thread = new Thread(){

                @Override
                public void run() {
                    try{
                        sleep(100);
                    }catch(InterruptedException e){
                        e.printStackTrace();
                    }
                }
            };
            thread.start();
        }

}

in API level 19 or less, progress bar is like:

And in Marshmallow Nexus 7, it's like:

I have changed the build versions also in activity.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Piyush Soni
  • 45
  • 13
  • refer http://stackoverflow.com/questions/10951978/change-progressbar-color-through-code-only-in-android – sasikumar Jan 21 '16 at 06:12
  • @sasikumar Nope, its not helping, but thanks – Piyush Soni Jan 21 '16 at 06:41
  • @PiyushSoni Add more code like your `values/styles.xml` and `values-21/styles.xml` – Akshay Chordiya Jan 21 '16 at 15:07
  • values 21 xml is there, > do i have to add for marshmallow too like values 23 or something? – Piyush Soni Jan 22 '16 at 04:53

0 Answers0