Android PrograssBar style - android

Why my prograssbar is not shown as a moving prograssbar? It is just a white bar there .
Here is my code , Please help me with this,thank you !
Ive tried to change the color code but still not working .
I want it be something like this :
http://developer.android.com/design/media/progress_themes.png
But in this color :002a5c
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#android:id/background">
<shape>
<corners android:radius="0dip" />
<gradient
android:angle="90"
android:centerColor="#F8F8FF"
android:centerY="0.75"
android:endColor="#ffffff"
android:startColor="#C0C0C0" />
<stroke
android:width="25dp"
android:color="#002a5c" />
</shape>
</item>
<item android:id="#android:id/progress">
<clip>
<shape>
<corners android:radius="0dip" />
<gradient
android:angle="90"
android:endColor="#002a5c"
android:startColor="#002a5c" />
<stroke
android:width="25dp"
android:color="#002a5c" />
</shape>
</clip>
</item>
</layer-list>

Related

Android-Horizontal Gradient Progress bar showing full progress

Progress bar with progress drawable is not showing correct progress. It's showing full progress instead of set progress value.
progress bar xml
<ProgressBar
style="#style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_centerVertical="true"
android:layout_toRightOf="#id/rewardScore"
android:layout_width="match_parent"
android:id="#+id/userProgress"
android:max="100"
android:background="#drawable/progress_white_bg"
android:layout_marginLeft="10dp"
android:layout_height="10dp"
android:progress="40"
android:progressDrawable="#drawable/gradient_progress"
/>
gradient_drawable.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">
<shape>
<corners android:radius="100dp"/>
<gradient
android:startColor="#color/white"
android:endColor= "#color/white"
/>
</shape>
</item>
<item android:id="#android:id/progress">
<shape>
<corners android:radius="100dp"/>
<gradient
android:startColor="#color/progress_gradient_one"
android:endColor="#color/progress_gradient_two"
/>
</shape>
</item>
</layer-list>
Issue is in gradient_progress drawable. set this property in gradient
tag of second item: android:useLevel="true":
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<shape>
<corners android:radius="1dp" />
<gradient
android:endColor="#fff"
android:startColor="#fff" />
</shape>
</item>
<item android:id="#android:id/progress">
<shape>
<corners android:radius="1dp" />
<gradient
android:endColor="#6aae33"
android:startColor="#e61313"
android:useLevel="true" />
</shape>
</item>
the trick is in adding the <clip> tag to the progress item
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<shape>
<corners android:radius="100dp"/>
<gradient
android:startColor="#color/white"
android:endColor= "#color/white"
/>
</shape>
</item>
<item android:id="#android:id/progress">
<clip>
<shape>
<corners android:radius="100dp"/>
<gradient
android:startColor="#color/progress_gradient_one"
android:endColor="#color/progress_gradient_two"
/>
</shape>
</clip>
</item>
</layer-list>

Android - How to put round corner on the running progress in a progress bar using custom xml drawable as background

I'm using a custom drawable for my progress bar:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<shape>
<corners android:radius="15dp" />
<solid android:color="#color/light_grey" />
</shape>
</item>
<item android:id="#android:id/progress" >
<clip>
<shape>
<corners android:radius="15dp" />
<solid android:color="#color/indigo" />
</shape>
</clip>
</item>
</layer-list>
and it looks like:
Now, the background appears with a round corner, but the progress (inside) is straight, and I want to make it round too, like this:
I googled but didn't find any solution.
Any ideas on how can I achieve this round corner on progress?
Thanks!
you can see example of view here
you can modify the color and size of the thumb and seekbar to do what you want.
This solution was the only way i could do this.
Hope this help
this is my seekbar :
<SeekBar
android:id="#+id/simpleProgressBar"
android:layout_width="fill_parent"
android:layout_height="12dp"
android:max="100"
android:progress="0"
android:background="#null"
android:shape="oval"
android:splitTrack="false"
android:progressDrawable="#drawable/progress_background"
android:secondaryProgress="0"
android:thumbOffset="10dp"
android:thumb="#drawable/oval_seekbar_thumb" />
this is (progress_background.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">
<shape android:shape="rectangle">
<corners android:radius="5dp" />
<gradient
android:angle="270"
android:endColor="#color/grey_line"
android:startColor="#color/grey_line" />
</shape>
</item>
<item android:id="#android:id/secondaryProgress">
<clip>
<shape android:shape="oval">
<corners android:radius="5dp" />
<gradient
android:angle="270"
android:endColor="#color/blue"
android:startColor="#color/blue" />
</shape>
</clip>
</item>
<item android:id="#android:id/progress">
<clip>
<shape android:shape="rectangle">
<corners android:radius="90dp" />
<gradient
android:angle="90"
android:endColor="#color/colorPrimaryDark"
android:startColor="#color/colorPrimary" />
</shape>
</clip>
</item>
and this is the thumb (oval_seekbar_thumb.xml) :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="#ffffff" />
<stroke android:color="#color/colorPrimaryDark" android:width="3dp"/>
<size android:height="12dp" android:width="12dp"/>
</shape>
</item>
</selector>
The height of the thumb should be same as the height of the seekbar to look properly.
Replace the <clip> tag with <scale android:scaleWidth="100%">. This should give the curved edges to secondary progress
I know maybe it is obsolete question,but, just remove <clip> tag.

SeekBar Thumb Background Issue

Attache the image for reference Image Screenshot
Please find the code of my layout below..I m new to android ..Trying to learn...Stuck with this from past few days...
I dont want to see that background as white for thumb
Let me know in case any details are required..
Attache the image for reference
Thumb.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape = "oval"
android:tintMode="multiply">
<gradient
android:angle="360"
android:endColor="#color/colorPrimaryDark"
android:startColor="#color/colorPrimaryDark" />
<size
android:height="5dp"
android:width="5dp"/>
</shape>
SeekBar:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#android:id/background">
<shape android:shape="rectangle">
<corners android:radius="5dp"/>
<gradient
android:endColor="#6c6e6a"
android:startColor="#61635f" />
</shape>
</item>
<item android:id="#android:id/secondaryProgress">
<clip>
<shape android:shape="rectangle" >
<corners android:radius="5dp" />
<gradient
android:endColor="#303F9F"
android:startColor="#303F9F" />
</shape>
</clip>
</item>
<item android:id="#android:id/progress">
<clip>
<shape android:shape="rectangle" >
<corners android:radius="5dp" />
<gradient
android:endColor="#303F9F"
android:startColor="#303F9F" />
</shape>
</clip>
</item>
</layer-list>
Content:
<SeekBar
android:id="#+id/ProgressBar"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:progress="20"
android:progressDrawable="#drawable/seekbar_size"
android:thumb="#drawable/thumb3"
/>

How to set progressbar background

I have set the progressbar style using the below code.
I have declared the progressbar widget:
<ProgressBar
android:id="#+id/loadProgress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="20dip"
android:max="100"
android:progressDrawable="#drawable/load_progress"
android:progress="0" />
defined the "#drawable/load_progress"
<?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/background_bk">
</item>
<item
android:id="#android:id/progress"
android:drawable="#drawable/progress_bk">
</item>
</layer-list>
defined the "#drawable/background_bk" (it is red)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="0"
android:endColor="#ff0000"
android:startColor="#ff0990" />
<stroke
android:width="1dp"
android:color="#ff0000" />
</shape>
defined the #drawable/progress_bk (it is green)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="0"
android:endColor="#00ff00"
android:startColor="#00ff00" />
<stroke
android:width="1dp"
android:color="#00ff00" />
</shape>
The progressbar always shows totally green (which is how it should appear when the progress value is 100), even if I set the progress value to less than 100. Any input would be appreciated.
Here is what I did to have a progress bar that was green with clear background:
android:background="#color/white"
android:progressBackgroundTint="#color/white"
android:progressTint="#color/green_light"
Finally, I find a easy solution.
1
you can find the default drawable xml file in your folder
"SDK_path\platforms\android19\data\res\drawable"
Overthere you can find many default style of many widgets.
2
and get the file "progress_horizontal.xml".
the codes in that file is:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#ff9d9e9d"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#ff747674"
android:angle="270"
/>
</shape>
</item>
<item android:id="#android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
<item android:id="#android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#ffffd300"
android:centerColor="#ffffb600"
android:centerY="0.75"
android:endColor="#ffffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
</layer-list>
3
you can easily change the color of the "progress color" and "background color".

Custom horizontal progressbar

Hey,
I just wrote a horizontal progress bar. The progressbar gets this background resource:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="#drawable/progress_bg" />
</item>
<item android:id="#android:id/progress" android:gravity="center">
<clip>
<shape>
<corners android:radius="5dip" />
<solid android:color="#FFF" />
</shape>
</clip>
</item>
This works fine, but the white progress has the same height as the background. But I want the progress to be smaller than the background of the progress bar, since thre background has a boarder that should not overlap.
Any ideas?
Thanks
There is also :
<item android:id="#android:id/secondaryProgress"></item>
Did you changed it too?
http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList
You can try adding android:top, android:left,android:right, and android:bottom to the white progress bar item in order to add padding to the bar.
<item android:id="#android:id/progress" android:gravity="center"
android:top="2dp" android:left="2dp" android:right="2dp" android:bottom="2dp">
<clip>
<shape>
<corners android:radius="5dip" />
<solid android:color="#FFF" />
</shape>
</clip>
</item>
Hi actually I did not use it.
The full xml is:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="#drawable/progress_bg" />
</item>
<item android:id="#android:id/secondaryProgress" android:gravity="center">
<clip>
<shape>
<corners android:radius="5dip" />
<solid android:color="#FFF" />
</shape>
</clip>
</item>
Cheers
hi try adding stroke that has no color (opacity is max)
I tried this code with my gradient progress bar:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#android:id/background">
<shape>
<corners android:radius="10dip" />
<gradient
android:angle="270"
android:centerColor="#f8d79b"
android:centerY="0.5"
android:endColor="#f8d79b"
android:startColor="#f8d79b" />
</shape>
</item>
<item android:id="#android:id/progress">
<clip>
<shape>
<stroke
android:width="5px"
android:color="#00ffffff" />
<corners android:radius="10dip" />
<gradient
android:angle="0"
android:endColor="#ffac17"
android:startColor="#ffac17" />
</shape>
</clip>
</item>
</layer-list>
so your code should be like this:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="#drawable/progress_bg" />
</item>
<item android:id="#android:id/secondaryProgress" android:gravity="center">
<clip>
<shape>
<stroke
android:width="5px"
android:color="#00ffffff" />
<corners android:radius="5dip" />
<solid android:color="#FFF" />
</shape>
</clip>
</item>
worked for me, hope it works for you :D

Categories

Resources