android


How to edit Widget.Spinner press effect for color change in Android


I am using
following style to show spinner which is having custom style
<TableRow
android:id="#+id/tblRwSpn11"
style="#style/TableRowStyle" >
<Spinner
android:id="#+id/btnDashCust1"
style="#style/ButtonStyleSpinner1"
android:layout_marginTop="5dp"
android:layout_span="2"
android:textSize="10sp" />
</TableRow>
<style name="ButtonStyleSpinner1" parent="#android:style/Widget.Spinner">
<item name="android:textColor">#color/black</item>
<item name="android:layout_height">35dp</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:layout_marginRight">10dp</item>
<item name="android:paddingLeft">15dp</item>
<item name="android:textSize">#dimen/twelveTextSize</item>
</style>
in my SDK style.xml
<style name="Widget.Spinner">
<item name="android:background">#android:drawable/btn_dropdown</item>
<item name="android:clickable">true</item>
<item name="android:spinnerMode">dialog</item>
<item name="android:dropDownSelector">#android:drawable/list_selector_background</item>
<item name="android:popupBackground">#android:drawable/spinner_dropdown_background</item>
<item name="android:dropDownVerticalOffset">-10dip</item>
<item name="android:dropDownHorizontalOffset">0dip</item>
<item name="android:dropDownWidth">wrap_content</item>
<item name="android:popupPromptView">#android:layout/simple_dropdown_hint</item>
<item name="android:gravity">center</item>
</style>
and #android:drawable/btn_dropdown as follows
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_window_focused="false" android:state_enabled="true"
android:drawable="#drawable/btn_dropdown_normal" />
<item
android:state_window_focused="false" android:state_enabled="false"
android:drawable="#drawable/btn_dropdown_disabled" />
<item
android:state_pressed="true"
android:drawable="#drawable/btn_dropdown_pressed" />
<item
android:state_focused="true" android:state_enabled="true"
android:drawable="#drawable/btn_dropdown_selected" />
<item
android:state_enabled="true"
android:drawable="#drawable/btn_dropdown_normal" />
<item
android:state_focused="true"
android:drawable="#drawable/btn_dropdown_disabled_focused" />
<item
android:drawable="#drawable/btn_dropdown_disabled" />
</selector>
output :
My Theme
<style name="MyTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/thin_ab_style</item>
</style>
<style name="MyActionBar" parent="android:style/Theme.Holo.Light">
<item name="android:background">#color/blue</item>
<item name="android:actionBarSize">2dp</item>
</style>
<style name="thin_ab_style" parent="android:Widget.Holo.ActionBar">
<item name="android:height">30dp</item>
<item name="android:background">#color/blue</item>
<item name="android:textSize">12sp</item>
<item name="android:textColor">#color/white</item>
</style>
it shows orange color for my spinner even if i have not set
so from where it is getting set? Please check above styles I applied to spinner
the press effect should show either blue or gray according to theme
Just write a basic Adapter extends ArrayAdapter<Type> like doing as List View.
Override getView method for that view that you want to change.
Override getDropDown view that opened when spinner pressed.
Lastly dont forget to call Spinner.setAdapter(mAdapter)
And you can use your custom layouts to change colors or anything you want.
Good luck there.

Related Links

This listview lags even after using viewholder
Is Firebase Cloud Messaging free?
Can Android Speech Recognition work in background?
FirebaseAuth.getInstance().getCurrentUser() returns previously logged out user
RecyclerView adds items multiple times
Uploading an Android app for Beta - Package Error
Is android (AVD) command still supported?
Strength issue while pick Image from gallery in Android
Regarding Fused location Provider in Android to Fetch Location
How to download a pdf file from Inside the apk/res directory
How to use Retrofit2 + GSON -> Class with custom object?
android can't switch nested fragment/ childFragment
Android - Geofence trigger when lost gps
How can I make my toolbar a gradient in colors.xml?
AppBarLayout elevation hides toolbar
Error while showing file from a url in google docs using android web view

Categories

HOME
hyperlink
fuelux
ng-idle
nvd3.js
dns
webdriver
android-studio-2.2
google-spreadsheet
package
bitbucket-api
alsa
mips
nested-if
trac
nfs
openstreetmap
google-chrome-app
enterprise-architect
esoteric-languages
android-7.0-nougat
breadth-first-search
question2answer
dataflow-diagram
displaytag
froala
data.stackexchange.com
itunes
beautifier
gpio
corpus
appirater
ms-access-2003
8051
intersystems-cache
quantlib
dumpbin
android-maps-extensions
baidu-map
python-pptx
graphhopper
ideascript
visa
install.packages
http-request
drupal-theming
signal-strength
oim
getchar
automapper-5
identification
activeperl
datamaps
pair-programming
truezip
boo
reshape
lsyncd
bootstrap-tags-input
sandcastle
reachability
donations
x-tag
installshield-2010
expectations
hadoop-partitioning
lz77
kendo-upload
google-books
fuelcms
mod-proxy
jdk1.7
dulwich
haskell-warp
nutiteq
diff3
shopizer
openbabel
appserver
psr-4
rmysql
ios8-extension
kendo-dataviz
model-driven-development
hidapi
workitem
virtual-pc
uimanageddocument
veracity
gobject-introspection
saxparseexception
xcelsius
clrstoredprocedure
cdonts
twitterizer
murmurhash
windows-identity
wspbuilder
great-circle

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App