this should be a very easy to customize style...
i want a horizontal progress bar that is slithly thick (or that i can customize the thickness) and the color matches the apps color
if i do
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#id/textLoading"
android:layout_centerHorizontal="true"
android:indeterminate="true"
/>
the progress bar is horizontal and matches app visual identity... but is too thin... the person need glases to see it
if i do
<ProgressBar
android:id="#+id/progressBar"
style="android:Widget.ProgressBar.Horizontal"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#id/textLoading"
android:layout_centerHorizontal="true"
android:indeterminate="true"
/>
the progress bar is good thickness but the color is a stupid yellow that matches nothing in this plannet
how can i customize individual parameters???
there are many ways to achieve what you need:
1- use android:scaleY="8" in your XML file
or from code
mProgressBar.setScaleY(3f);
2- style="#android:style/Widget.ProgressBar.Horizontal"
this will make you have Horizontal progress bar, so you can inherit it in styles and edit it as follows:
<style name="CustomProgressBarHorizontal" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/custom_progress_bar_horizontal</item>
<item name="android:minHeight">10dp</item>
<item name="android:maxHeight">20dp</item>
</style>
Here is an example for a progress bar:
<ProgressBar
android:id="#+id/progressBar"
style="#android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="20dp"
android:progressDrawable="#drawable/my_progressbar" />
and here is my_progressbar.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:gravity="center_vertical|fill_horizontal">
<shape android:shape="rectangle">
<corners android:radius="10dp"/>
<size android:height="20dp"/>
<solid android:color="#color/blue"/>
</shape>
</item>
<item
android:id="#android:id/progress"
android:gravity="center_vertical|fill_horizontal">
<scale android:scaleWidth="100%">
<shape android:shape="rectangle">
<corners
android:radius="10dp"
/>
<size android:height="20dp"/>
<solid android:color="#color/yellow"/>
</shape>
</scale>
</item>
</layer-list>
Here is an example of how it looks:
You can use Android Material Progress Bar:
com.google.android.material.progressindicator.LinearProgressIndicator
XML example:
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="#+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="45"
app:indicatorColor="#color/blue_light"
app:trackColor="#FFFFFF"
app:trackCornerRadius="5dp"
app:trackThickness="10dp" />
Now you can use app:trackThickness to adjust the thickness of the progress bar
You can also check out Google's Material Design page regarding Material Progress Bar here: https://material.io/components/progress-indicators/android#using-progress-indicators
You can customize the style with:
<ProgressBar
android:id="#+id/progressBar"
android:indeterminate="true"
style="#style/CustomProgressBar"
with:
<style name="CustomProgressBar" parent="Widget.AppCompat.ProgressBar.Horizontal">
<item name="minHeight">32dip</item> <!-- default 16dp -->
<item name="maxHeight">32dip</item> <!-- default 16dp -->
</style>
If you want to customize the color use:
<ProgressBar
style="#style/CustomProgressBar"
android:indeterminate="true"
android:theme="#style/CustomProgressBarTheme"
/>
with:
<style name="CustomProgressBarTheme">
<item name="colorControlActivated">#color/....</item>
</style>
Related
I want to customize my searchview edittext which expanded when I click on searchview icon to be like this image
And I tried the custom style to do that but I got this result in this image
The problems:
There is a blue vertical bar at the start of the edittext I need to remove it and make it appears only on a search query and after the querytext also I want to change the color of this vertical bar
I need to add a white search icon with specific padding of the hint and text query currently the white icon in the result screen disappears on search query
How I got this result?
I define searchViewStyle
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
<item name="searchIcon">#drawable/ic_baseline_dark_search_24</item>
<item name="closeIcon">#null</item>
<item name="goIcon">#drawable/ic_baseline_dark_search_24</item>
<item name="commitIcon">#drawable/ic_baseline_dark_search_24</item>
<item name="android:editTextColor">#color/white</item>
<item name="android:textColorHint">#color/white</item>
<item name="android:textColorHighlight">#color/red</item>
<item name="queryBackground">#drawable/radius_drawable</item>
<item name="searchHintIcon">#drawable/ic_baseline_search_24</item>
<item name="queryHint">"search_hint"</item>
</style>
I define searchview like this in my fragment layout
<androidx.appcompat.widget.SearchView
android:id="#+id/searchView"
style="#style/SearchViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
</androidx.appcompat.widget.SearchView>
I define a custom drawable background for searchview
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:radius="18dp"
/>
<solid
android:color="#4F4F4F"
/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size
android:width="270dp"
android:height="60dp"
/>
</shape>
While I do not clearly understand what your requirements are exactly, I would like to point out one thing though.
For Applying a style to a SearchView we have to use the theme attribute, your code seems okay, maybe your changes are not being applied for now I believe. So try using the android:theme attribute for your style as follows. The rest of your requirements should easily come by to you with some trial and error I believe. Thanks.
<androidx.appcompat.widget.SearchView
android:id="#+id/searchView"
android:theme="#style/SearchViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
Here is how I would recommend you to update your style to get as close as possible to your design.
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
<item name="searchIcon">#drawable/ic_baseline_dark_search_24</item>
<item name="queryBackground">#android:color/transparent</item>
<item name="queryHint">"search_hint"</item>
<item name="iconifiedByDefault">false</item>
<item name="android:textColorHint">#color/white</item>
<item name="android:background">#drawable/radius_drawable</item>
</style>
And you can modify your drawable and get rid of the padding and size since you are using wrap_content in your layout
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#4F4F4F" />
<corners android:radius="18dp" />
</shape>
You can use custom searchview in AppCompat SearchView . Copy searchview from this link searchview.xml
Then edit the xml or remove the extra margin from xml.
Add custom searchview layout like this:
<androidx.appcompat.widget.SearchView
android:id="#+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:gravity="center"
app:layout="#layout/custom_search_view"
app:iconifiedByDefault="true"
app:queryBackground="#android:color/transparent"
app:queryHint="Search"
app:searchIcon="#drawable/search" />
I have a cardview. The button default color is grey. I want it to look like the right side image(like the blessings). This right one has been created setting backgroundtint to white but in older versions its still shows grey.
<android.support.v7.widget.CardView
android:id="#+id/programm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
card_view:cardCornerRadius="2dp"
android:layout_alignParentBottom="true"
android:layout_margin="6dp"
card_view:cardElevation="6dp"
android:layout_gravity="end|right"
card_view:cardBackgroundColor="#color/hotpink"
android:onClick="openNextActivity">
<Button
android:layout_width="wrap_content"
android:drawable="#color/white"
android:layout_height="wrap_content"
android:text="#string/Programme"
android:textColor="#color/hotpink"
android:onClick="openNextActivity"
/>
</android.support.v7.widget.CardView>
If i change the background of the button to white the entire color changes to white:
<android.support.v7.widget.CardView
android:id="#+id/programm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
card_view:cardCornerRadius="2dp"
android:layout_alignParentBottom="true"
android:layout_margin="6dp"
card_view:cardElevation="6dp"
android:layout_gravity="end|right"
card_view:cardBackgroundColor="#color/hotpink"
android:onClick="openNextActivity">
<Button
android:layout_width="wrap_content"
android:drawable="#color/white"
android:background="#color/white"
android:layout_height="wrap_content"
android:text="#string/Programme"
android:textColor="#color/hotpink"
android:onClick="openNextActivity"
/>
</android.support.v7.widget.CardView>
As per google search, this default grey color is set in some theme.I probably need to overwrite some theme and set some attribute. But I am not sure what do I need to change.
Try this:
<Button
android:layout_width="wrap_content"
android:text="Button Text"
android:theme="#style/myButtonTheme"
android:layout_height="wrap_content"/>
set this myButtonTheme in your styles.xml file:
<style name="myButtonTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColorPrimary">#color/white</item>
<item name="colorButtonNormal">#5552f1</item>
</style>
[ set your desired background color in colorButtonNormal ]
Output:
i haven't tested it for this kind of situation, but i think something like this can work
you can create a background.xml in your drawable directory and set it as background
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<item>
<shape>
<!-- set the shadow color here -->
<stroke
android:width="3dp"
android:color="#77000000" />
<!-- setting the thickness of shadow (positive value will give shadow on that side) -->
<padding
android:bottom="3dp"
android:left="1dp"
android:right="3dp"
android:top="1dp" />
<corners android:radius="4dp" />
</shape>
</item>
<!-- Background -->
<item>
<shape>
<solid android:color="#fff" />
<corners android:radius="4dp" />
</shape>
</item>
things you can try with this is that you can set the shadow color the color you want or something else that i had in mind was set the opacity of shadow color to zero so that it would be transparent and you can set its thickness by the paddings of the shadow
hope this helps
In yout styles define:
<style name="BlueButtonTheme" parent="#style/AppTheme">
<item name="android:buttonStyle">#style/Widget.AppCompat.Button.Colored</item>
<item name="colorButtonNormal">#color/disabledButtonColor</item>
<item name="colorAccent">#color/enabledButtonColor</item>
<item name="android:disabledAlpha">1</item>
<!-- button text color-->
<item name="android:textColor">#drawable/colored_button_text_color</item>
</style>
And in your layout xml file:
<Button
android:id="#+id/buttonId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:theme="#style/BlueWhiteButtonTheme"
android:text="#string/buttonLabel"/>
Just set background for button in your layout
<Button
android:background="#android:color:white"
</Button>
I created this progress bar for my app, but I cant get that yellow orangy color that appears to change to something like red or blue.
<ProgressBar
android:id="#+id/progress_bar"
style="#android:style/Widget.ProgressBar.Horizontal"
android:layout_width="250sp"
android:layout_height="wrap_content"
android:progress="2"
android:layout_marginTop="82dp"
android:max="3"
android:indeterminate="false"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true" />
above is my progress bar xml code.
Any help guys? :)
Thanks so much in advance! :)
If android version is 5.0 and above you just need to set
android:indeterminateTint="#color/BLACK"
android:indeterminateTintMode="src_in"
For lower version I use this
mProgressBar.getIndeterminateDrawable().setColorFilter(getResources()
.getColor(R.color.primary_color),PorterDuff.Mode.SRC_IN);
Create a new XML file in your drawable folder called something like custom_progress_bar.xml and paste this there:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Define the background properties like color etc -->
<item android:id="#android:id/background">
<clip>
<shape>
<solid android:color="#000000" />
</shape>
</clip>
</item>
<!-- Define the progress properties like start color, end color etc -->
<item android:id="#android:id/progress">
<clip>
<shape>
<solid android:color="#FFFFFF" />
</shape>
</clip>
</item>
</layer-list>
And in your <ProgressBar> add this attribute:
android:progressDrawable="#drawable/custom_progress_bar"
Change the 2 colors to your own preference. I put #FFFFFF and #000000 which are white and black.
Go to your styles.xml and change the colorAccent value from your base application theme e.g.
<item name="colorAccent">{COLOR}</item>
I am using minSdkVersion 15 and it worked for me.
If you want to change the ProgressBar color, not by drawable, you can use this style as theme for the ProgressBar
<style name="ProgressBar" parent="Widget.AppCompat.ProgressBar">
<item name="colorAccent">#color/white_primary</item>
</style>
If android:indeterminateTint doesn't work, try this:
<ProgressBar
android:id="#+id/progress_bar"
style="#android:style/Widget.ProgressBar.Horizontal"
android:progressTint="#color/Red" <--------------------------
android:progressBackgroundTint="#color/Blue" <---------------
android:layout_width="250sp"
android:layout_height="wrap_content"
android:progress="2"
android:layout_marginTop="82dp"
android:max="3"
android:indeterminate="false"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true" />
Try this and add you custom color
Progressbar mBar= (ProgressBar) findViewById(R.id.spinner);
mBar.getIndeterminateDrawable().setColorFilter(Color.parseColor("#80DAEB"),
android.graphics.PorterDuff.Mode.MULTIPLY);
Hope this helps
For future references:
For API 21+ we can use directly in the XML:
android:indeterminateTint="#android:color/white"
set theme in style.xml like this
<style name="ProgressBar" parent="Widget.AppCompat.ProgressBar">
<item name="colorAccent">#color/dark_blue</item>
</style>
then use this style as "theme" in progressBar like this,
<ProgressBar
android:id="#+id/progressBar"
android:theme="#style/ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="440dp"
app:layout_constraintEnd_toEndOf="#+id/splashTitle"
app:layout_constraintHorizontal_bias="0.493"
app:layout_constraintStart_toStartOf="#+id/splashTitle"
app:layout_constraintTop_toBottomOf="#+id/splashTitle" />
Happy coding
Styling determinate progress bar is easy, there are many tutorials to achieve that. This is on I'm using:
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#drawable/progress_background"
android:progressDrawable="#drawable/progress"
android:id="#+id/progressBar" />
Drawable progress_background.xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/progress">
<clip>
<shape>
<solid android:color="#color/colorAccent" />
<corners android:radius="4dp" />
</shape>
</clip>
</item>
</layer-list>
It looks like this:
But when progress is not available yet, I'd like to use indeterminate one. So I tried:
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#drawable/progress_background"
android:progressDrawable="#drawable/progress"
android:indeterminateTint="#color/colorAccent"
android:indeterminateTintMode="src_in"
android:indeterminate="true"
android:id="#+id/progressBar" />
But indeterminate progress is not stretched to bar height:
I tried to style it using drawable file as well but it looked like broken determinate progress bar (filling from 0 to 100 all over again).
Desired indeterminate progress bar should look like regular one but with 8dp height and rounded corners.
Default indeterminate progress bar animation use a non 9-patch pngs. So it can't be stretched over your 8dp height progress bar. You should add android:indeterminateDrawable with custom animation:
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="#drawable/progressbar_indeterminate1" android:duration="50" />
<item android:drawable="#drawable/progressbar_indeterminate2" android:duration="50" />
<item android:drawable="#drawable/progressbar_indeterminate3" android:duration="50" />
...
<item android:drawable="#drawable/progressbar_indeterminateX" android:duration="50" />
</animation-list>
Then make drawables to animate it like this (it can be xml or image or 9-patch):
Animation frame 1
Animation frame 2
Never versions of android (api21+) use AnimatedVectorDrawable for indeterminate ProgressBar.
I saw that a lot of people are looking on this post so I thought that I should edit it and share an example:
Note (this example is not complete, it's still in progress but I guess it's a starting point)
GitHub: Github Example
The important part in this example is below: Create in drawable a xml file custom_progress_bar_horizontal.xml and add the content below.
<?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>
<padding
android:bottom="3dip"
android:top="3dip"
android:left="3dip"
android:right="3dip"/>
<corners
android:radius="5dip" />
<gradient
android:startColor="#2a2b2f"
android:centerColor="#2a2b2f"
android:centerY="0.50"
android:endColor="#2a2b2f"
android:angle="270" />
</shape>
</item>
<item
android:id="#android:id/progress">
<clip>
<shape>
<corners
android:radius="5dip" />
<gradient
android:startColor="#ff0e75af"
android:endColor="#ff1997e1"
android:angle="90" />
</shape>
</clip>
</item>
</layer-list>
Add the following code in styles.xml
<style name="CustomProgressBar" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">#drawable/custom_progress_bar_horizontal</item>
<item name="android:minHeight">10dip</item>
<item name="android:maxHeight">20dip</item>
</style>
After you have added the style in your activity layout add:
<ProgressBar
android:id="#+id/customProgress"
style="#style/CustomProgressBar"
android:layout_width="match_parent"/>
The progress dispaly below in a frame it's a little tricky because you need to extend the ProgressBar class and make the changes there.
I will leave here some examples and notify when I will add them in my github project.
Great example if you want to disaply the progress in your way: NumberProgressBar
Other progress bar examples:
Custom progress bar 1
Custom progress bar 2
For more detail visit here. Android horizontal progress bar?
You know, android has a View named: LinearProgressIndicator
you can have indeterminate animation in the horizontal progress bar with that.
<com.google.android.material.progressindicator.LinearProgressIndicator
android:layout_width="280dp"
android:layout_height="12dp"
android:indeterminate="true"
app:indicatorColor="#color/app_brand_primary"
app:trackColor="#color/color_divider"
app:trackCornerRadius="6dp"
app:trackThickness="12dp" />
p.s - it has a weird behaviour for toggling the indeterminate value programmatically. to do that you should
set visibility to invisible,
set indeterminate boolean,
then show the view again.
example :
progress.isVisible = false
progress.isIndeterminate = true
progress.isVisible = true
Issue :
https://github.com/material-components/material-components-android/issues/1921
i have activities which i themed with my custom theme, but for spinner i choosed to style it with Appcompat v21 but i got this :
So how to change the Spinner arrow to be black or blue if is there a way ?
i found this as similar question but doesn't have any answer : https://stackoverflow.com/questions/28561105/add-custom-spinner-arrow
here is my spinner :
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner2"
android:layout_marginTop="10dp"
android:layout_centerInParent="true" />
i used this to style the spinner:
<style name="MyTheme.SpinnerAppTheme" parent="Widget.AppCompat.Spinner">
</style>
this is how i use the adapter
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
getBaseContext(), R.array.listMedRes, android.R.layout.simple_spinner_item);
i just want to theme the spinner , thanks alot
Might be late but better late than never. To respond to your question: "Is there a way to use it only in spinner?". The answer is yes, refer to the code below.
Add this code to your theme or style file
<style name="customSpinnerTheme" parent="yourAppThemeThatUseAppCompat21">
<item name="colorControlNormal">#eaeaea</item>
<item name="colorControlActivated">#000000</item>
<item name="colorControlHighlight">#000000</item>
</style>
Then in your XML that use spinner you can add this line
android:theme="#style/customSpinnerTheme"
e.g.
<Spinner
android:theme="#style/customSpinnerTheme"
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:spinnerMode="dialog" />
Since you are using AppCompat-v21, you can take advantage of the new material design styles attributes:
colorPrimary: your app branding color for the app bar, applies to action bar
colorPrimaryDark: darker variant for the status bar and contextual app bars
colorAccent: lets you define bright complement to the primary branding color. By default, this is the color applied to framework controls (via colorControlActivated)
colorControlNormal: color applied to framework controls in their normal state
colorControlActivated: applied to framework controls in their activated
Here is an example for you
styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#color/primary</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#color/primary_dark</item>
<!-- colorAccent is used as the default value for colorControlActivated which is used to tint widgets -->
<item name="colorAccent">#color/accent</item>
<item name="colorControlNormal">#color/primary</item>
</style>
colors.xml
<resources>
<color name="primary">#ff0000ff</color>
<color name="primary_dark">#ff0000af</color>
<color name="accent">#870000ff</color>
<color name="white">#ffffffff</color>
</resources>
Here is how it looks
Hope this helps.
There is a way to change your arrow color... actually it's not color you can change this image with blue color image..
create a xml file myspinner_selector in your drawable folder
and paste
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item><layer-list>
<item><shape>
<gradient android:angle="90" android:endColor="#ffffff" android:startColor="#ffffff" android:type="linear" />
<stroke android:width="1dp" android:color="#504a4b" />
<corners android:radius="5dp" />
<padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
</shape></item>
<item ><bitmap android:gravity="bottom|right" android:src="#drawable/blue_arrow" /> // you can use any other image here, instead of default_holo_dark_am
</item>
</layer-list></item>
</selector>
blue_arrow is an image, and add this style in your style file
<style name="spinner_style" >
<item name="android:background">#drawable/myspinner_selector</item>
<item name="android:layout_marginLeft">5dp</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:layout_marginBottom">5dp</item>
<item name="android:paddingLeft">5dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
</style>
finally add this style in your spinner
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/spinner_style"
/>
it look like this. you need to customize
look at below code.
create spinner_bg.xml under drawable folder
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item><layer-list>
<item><shape>
<gradient android:angle="270" android:centerColor="#d0d0d0" android:endColor="#c5c6c6" android:startColor="#dbdadb" android:type="linear" />
<stroke android:width="1dp" android:color="#7a7a7a" />
<corners android:radius="1dp" />
<padding android:left="3dp" android:right="3dp" />
</shape></item>
<item><bitmap android:gravity="center|right" android:src="#drawable/dropdown_icon_black" />
</item>
</layer-list></item>
</selector>
write down below code in styles.xml
<style name="spinner_style">
<item name="android:background">#drawable/spinner_bg</item>
</style>
Apply style to spinner
<Spinner
android:id="#+id/spinner"
style="#style/spinner_style"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:focusable="true"
android:overlapAnchor="false"
android:paddingRight="10dp"
android:spinnerMode="dropdown"
android:textColor="#android:color/white" />
use this image for spinner drawable
you could tint it with the attribute tint color.
<Spinner android:id="#+id/spinner"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:backgroundTint="#color/white"
/>