SeekBar Thumb Background Issue - android

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"
/>

Related

Seekbar thumb with transparent right and left padding/margin

Summarize the problem:
Hello, I want to create Seekbar like this one in the design:
So the thumb has something like padding/margin at left and right and bars are rounded on both sides.
What I've tried so far:
I've already tried to create thumb picture like this:
Unfortunately, it turned out that I can't use this picture because I need to change this black halo around green point programmatically.
That's why I've built seekbar completely in XML (no pngs images):
Seekbar:
<SeekBar
android:id="#+id/player_seekbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="#style/SeekBarPlayer"
local:MvxBind="Max Duration; Progress SliderPosition, Mode=OneWay; SecondaryProgress Downloaded; Visibility(LivePlaybackToVisibility(CurrentTrack))"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView" />
SeekbarBackground:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="5dp" />
<solid android:color="#3d4b58" />
</shape>
</item>
</layer-list>
SeekbarSecondaryProgress:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/progressshapesecondary" >
<clip>
<shape
android:shape="rectangle" >
<size android:height="5dp"/>
<corners
android:radius="5dp" />
<solid android:color="#8883e76b"/>
</shape>
</clip>
</item>
</layer-list>
SeekbarProgress:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/progressshape" >
<clip>
<shape
android:shape="rectangle" >
<size android:height="5dp"/>
<corners
android:radius="5dp" />
<solid android:color="#83e76b"/>
</shape>
</clip>
</item>
</layer-list>
And it provides me a seekbar like this:
Summarazing
How can I achieve the following seekbar design from now on?
Use below code for thumb drawable:
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="#8883e76b"/>
<stroke android:color="#color/black" android:width="3dp"/>
<size android:height="30dp" android:width="30dp"/>
</shape>
</item>
</selector>
Use below code for seekbar, just change color what you want:
<item android:id="#android:id/background">
<shape android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="#color/fofo_grey" />
</shape>
</item>
<item android:id="#android:id/progress">
<clip>
<shape android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="#color/signup_green" />
<stroke
android:width="6dp"
android:color="#color/fofo_grey" />
</shape>
</clip>
</item>

How to customize seekbar android

Hello i am trying to customize a seekbar on android but i think there is something wrong on thumb view. the problem is two side of thumb.
hear is my code.
<SeekBar
android:id="#+id/seekBar"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:max="10"
android:thumb="#drawable/thm_s"
android:secondaryProgress="5"
android:progress="5"
android:progressDrawable="#drawable/seekbar_background"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="94dp" />
thm_s.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#ffffff"/>
<size
android:width="20dp"
android:height="20dp"/>
</shape>
seekbar_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/secondaryProgress">
<shape android:shape="rectangle">
<corners android:radius="10dp" />
<gradient
android:angle="270"
android:endColor="#403F41"
android:startColor="#403F41" />
</shape>
</item>
<item android:id="#android:id/progress">
<clip>
<shape android:shape="rectangle">
<corners android:radius="10dp" />
<gradient
android:angle="270"
android:endColor="#00AEEF"
android:startColor="#00AEEF" />
</shape>
</clip>
</item>
</layer-list>
please view this image.
https://drive.google.com/file/d/0BxpdBDS2CMCWTExFREVqVmt6Nk0/view?usp=drivesdk

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.

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".

Android PrograssBar style

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>

Categories

Resources