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

Android - Crash when clicking on RecyclerView when SwipeRefreshLayout loading
common runonUIthread for whole application
how to Fused location Run in Background service continuously
React-Native Twitter login for Android
How to dismiss progress bar once otp read from Inbox in android?
Idling resource exits even when isIdleNow() returns false in espresso
When adding Facebook SDK “ appeventslogger.activateapp(this)” is shown deprecated
Android marshmallow WifiManager leaking IntentReceiver
Adding ffmpeg OMX codec to Genymotion Android 4.4.2 emulator
Separate each rom listview android [closed]
Capturing a photo taken from a gallery intent
Android - Best approach for passing context in adapter (Specifically `RecyclerViewAdapter`)
Understanding Android Binders
android app is not visible in the play store after I pushed it to Open Beta
How to dynamically add preferences into preferences screen and bind their values?
Realm.io irrational big data usage on android

Categories

HOME
service-worker
google-app-engine
phpword
eslint
hessian
solaris
can
static-site
spring-data-mongodb
onclick
p2p
x-cart
radgridview
package.json
symfony-2.8
smartclient
enterprise-miner
database-connection
guzzle
r-mice
interpreter
xunit
jasmine-node
angular-translate
rpgle
ceylon
paragraph
gojs
biztalk-rule-engine
hibernate-search
release
avcapturedevice
oim
nanoc
google-cse
magic-draw
truezip
java-websocket
pure-css
rspec2
delta
boost-serialization
maybe
dynamics-nav-2016
dllimport
uncompress
osc
bcache
ejb-2.x
at-job
spy++
rickshaw
machine-instruction
personalization
matrix-inverse
embedded-fonts
c++builder-xe5
scmmanager
css-reset
windows-98
server-administration
midlet
vfs
os.system
lambdaj
inkcanvas
azman
gobject-introspection
denied
promotion-code
rmdir
multiplatform
clrstoredprocedure
maven-1
hbm2java
addchild
skype4java
glui
feasibility
unmanagedresources
cardspace
wspbuilder

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