how can i change spinner background color?

how to change spinner background color in android programmatically
change spinner text color android
android-spinner dropdown background color
android-spinner background arrow
how to change spinner text color in android programmatically
how to change spinner arrow color in android
change background color of the selected item in android spinner
custom spinner android

How can i change spinner background color ?

this black color from style .

How can i change style color for spinner pop up?

I want to change background color white in place of black How can i change ?

spinnner

<Spinner
    android:id="@+id/spinner"
    android:layout_width="100dp"
    android:layout_marginTop="1dp"
    android:layout_height="wrap_content"
    android:background="@drawable/spinner_bg"
    android:layout_marginLeft="1dp"/>

spinnerbg.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <color android:color="@color/InputBg1" />
    </item>
    <item android:gravity="center_vertical|right" android:right="8dp">
        <layer-list>
            <item android:width="12dp" android:height="12dp" android:background="#fff" android:gravity="center" android:bottom="10dp">
                <rotate
                    android:fromDegrees="45"
                    android:toDegrees="45">
                    <shape android:shape="rectangle">
                        <solid android:color="#ffffff" />
                        <stroke android:color="#ffffff" android:width="1dp"/>
                    </shape>
                </rotate>
            </item>
            <item android:width="20dp" android:height="10dp" android:bottom="21dp" android:background="#fff" android:gravity="center">
                <shape android:shape="rectangle">
                    <solid android:color="@color/InputBg1"/>
                </shape>
            </item>
        </layer-list>
    </item>
</layer-list>

Try this..Change Style in In res/values/styles.xml::-

<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:spinnerDropDownItemStyle">@style/mySpinnerItemStyle</item>
</style>

<style name="mySpinnerItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
    <item name="android:textColor">@android:color/white</item>
</style>

How to change the spinner background in Android?, setting options . In a project the job was to do a custom spinner with following type… android:background="@android:color/transparent" Background color makes the spinner items look different then the whole layout background because they look more bright and colorful. This type of functionality can be possible when we have add extra textview_with_background.xml file into our project and set the textview into spinner. So textview text become the spinner items background text. So here is the complete step by step tutorial for Change spinner items background color in android programmatically.

You can set the spinners background color in xml like this:

android:background="YOUR_HEX_COLOR_CODE"

and if you use the drop down menu with you spinner you can set its background color like this:

android:popupBackground="YOUR_HEX_COLOR_CODE"

To change text color I recommended to use custom text layout

Give your customized color and size to text in this file.

spinner_item.xml

<?xml version="1.0" encoding="utf-8"?>

<TextView  
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"
    android:textSize="20sp"
    android:gravity="left"  
    android:textColor="YOUR_HEX_COLOR_CODE"         
    android:padding="5dip"
    />

Now use this file to show your spinner items like:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_item,list);

You don't need to set the drop down resource. It will take spinner_item.xml only to show your items in spinner.

Custom Spinner Background Design in android, I am developing an app in which I need to change the spinner background layout to match the background color I researched and found that @color/InputBg should be replaced by the color you want as your background. First it fills the background with desired color. Then a child layer-list makes a square and rotates it by 45 degrees and then a second Rectangle with background color covers the top part of rotated square making it look like a down arrow.

You can simply add the following code inside <Spinner/> to change popup background.

android:popupBackground="COLOR_CODE"

Now the code should be as follow,

<Spinner
    android:id="@+id/spinner"
    android:layout_width="100dp"
    android:layout_marginTop="1dp"
    android:layout_height="wrap_content"
    android:background="@drawable/spinner_bg"
    android:layout_marginLeft="1dp"
    android:popupBackground="COLOR_CODE"
/>

How to change the spinner background design and color for android , how to change spinner background color in android programmatically android- spinner dropdown background color change spinner dropdown icon android A good way to customise spinners and any other Android controls is to use the Android Asset Studio site and choose the Android Holo Colors Generator. This will create all the assets you might need, including the “underline”. It also generates the XML files that implement the changes.

Create style like this in folder res/values/styles.xml

<style name="spinnerItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
    <item name="android:textColor">Put text color code here</item>
    <item name="android:background">Put background color code here</item>
</style>  

Apply to your spinner

<Spinner
    android:id="@+id/spinner"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    style="@style/spinnerItemStyle"/>

Change spinner background color but keep arrow, A simple solution that doesn't require you to create your own drawable for the arrow is to wrap the spinner with a RelativeLayout , and set the background color � Android change background color of spinner Archive the Spinner background style How to change the background color of selected spinner list item You can use

Couple of things need to do with customization spinner as per below :-

spinner_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>

<color android:color="@color/InputBg1" />
</item>
<item android:gravity="center_vertical|right" android:right="8dp">
<layer-list>
<item android:width="12dp" android:height="12dp"  android:gravity="center" android:bottom="10dp">
    <rotate
        android:fromDegrees="45"
        android:toDegrees="45">
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
            <stroke android:color="#ffffff" android:width="1dp"/>
        </shape>
    </rotate>
</item>
<item android:width="20dp" android:height="10dp" android:bottom="21dp" android:gravity="center">
    <shape android:shape="rectangle">
        <solid android:color="@color/InputBg1"/>
    </shape>
</item>
</layer-list>
</item>
</layer-list>

spinner_item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="@style/spinnerItemStyle"
    android:maxLines="1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="#ffffff"
    android:ellipsize="marquee"
    android:textAlignment="inherit"/>

spinner_dropdown_item.xml

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="@style/spinnerItemStyle"
    android:maxLines="1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textColor="#000000"
    android:ellipsize="marquee"/>

spinner

<Spinner
android:id="@+id/spinner"
android:layout_width="100dp"
android:popupBackground="#ffffff"
android:layout_marginBottom="1dp"
android:layout_height="wrap_content"
android:textColor="#ffff"
style="@style/spinnerItemStyle"
android:background="@drawable/spinner_bg"
android:layout_marginLeft="1dp" />

style.xml

<style name="spinnerItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
    <item name="android:textColor">#000000</item>
</style>

Creating adapter for spinner

ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, categories);
// Drop down layout style - list view with radio button
dataAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);

Change spinner background color but keep arrow, In this android kotlin source code example, we are going to dynamically change Spinner background color in Kotlin. You can copy and adopt this source code For those who want to change DrowDownIcon color you can use like this. spinner.getBackground().setColorFilter(Color.parseColor("#ffffff"), PorterDuff.Mode.SRC_ATOP);

How to dynamically change Spinner background color in Kotlin, This Android tutorial explains, How to get holo theme for Spinner in Android 2.x How to change the Spinner background style How to change the background� Spinner spinner = (Spinner) findViewById(R.id.spinner); // Set the adapter for the folder `Spinner`. spinner.setAdapter(resourceCursorAdapter); Because ResourceCursorAdapter uses the same bindView to populate the spinner when it is open and closed, the id of the TextView in spinner_dropdown_item.xml and spinner_item.xml must be the same.

Custom Spinner background with border XML, This video shows how to set background color for spinner and for the drop down view of the Duration: 3:09 Posted: May 6, 2020 If you want to customize or change spinner text color, you can achieve it in one of the following ways listed below. Change Spinner Text Color in XML layout. To achieve spinner text color change in android, we will change the color of each spinner item text in the drop down resource layout file. activity_spinner_text_color.xml

Android Change Background Color Of Spinner, For example, if your spinner contains fruits as an options. Here, you can use some text like “Select Fruit” as a search hint. Setting a search hint or prompt text in android spinner is not a tough task. But customizing them like changing text color, changing background color need little tricks. We will use two methods to implement search hint.

Comments
  • where i have to include this style ?
  • I am using custom spinner spinnerbg.xml If i am using this android:popupBackground="YOUR_HEX_COLOR_CODE" then whole pop up is white item text is not visible Daily,Monthly etc
  • either give another color. white color text is not visible with white background
  • How can i change text color ?
  • Used this but android:popupBackground="#ffffff" pop up background is white but does not appear text color as per updated answer .
  • I am using customize spinner as above code spinnerbg.xml .It is not working