I am trying to customize spinner. I found this tutorial, http://www.gersic.com/blog.php?id=57
It looks great but I am finding some errors all of which is like the following
error: No resource identifier found for attribute 'state_dropdown_showing' in package 'android'
and the xml which leads to this error is
<!-- DROPDOWN SHOWING-->
<item android:state_first="true"
android:state_dropdown_showing="true"
android:drawable="#drawable/btn_dropdown_down"
/>
<item android:state_middle="true"
android:state_dropdown_showing="true"
android:drawable="#drawable/btn_dropdown_up_down"
/>
<item android:state_last="true"
android:state_dropdown_showing="true"
android:drawable="#drawable/btn_dropdown_up"
/>
<item android:state_single="true"
android:state_dropdown_showing="true"
android:drawable="#drawable/btn_dropdown_neither_up_down"
/>
<!-- DROPDOWN NOT SHOWING-->
<item android:state_first="true"
android:state_dropdown_showing="false"
android:drawable="#drawable/btn_dropdown_right_only"
/>
<item android:state_middle="true"
android:state_dropdown_showing="false"
android:drawable="#drawable/btn_dropdown_left_right_collapsed"
/>
<item android:state_last="true"
android:state_dropdown_showing="false"
android:drawable="#drawable/btn_dropdown_left_only"
/>
<item android:state_single="true"
android:state_dropdown_showing="false"
android:drawable="#drawable/btn_dropdown_neither"
/>
And I am not finding anything in the net relevant to this. I am at a fix now. I want to change the look and feel of the regular spinner with nice color background.
Anybody please guide me about customization of spinner.
android:state_dropdown_showing it is worked on after r15 version only..so update the android sdk tools version.it is hopefully helpful to all
Related
I'm trying to add Font Awesome library to my android project but i just can't. I was reading each google result about this topic.
My menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/buzon"
android:icon="#drawable/ic_buzon"
android:title="#string/buzon" />
<item
android:id="#+id/objetivos"
android:icon="#drawable/ic_objetivos"
android:title="#string/objetivos" />
<item
android:id="#+id/home_action"
android:icon="#drawable/ic_go_home"
android:title="#string/title_home" />
<item
android:id="#+id/encuesta"
android:icon="#drawable/ic_encuesta"
android:title="#string/encuesta" />
<item
android:id="#+id/cursos"
android:icon="#drawable/ic_cursos"
android:title="#string/cursos" />
</menu>
I'm want to use Font Awesome icons in my items menu instead default android icons.
For references, i was trying to follow this guide without success.
How to use Font Awesome icon in android application?
I have some styles set up to work on different API's (one for v21 and one for anything below that). I want to have a style for my ImageButton but it doesn't seem to be working out the way I expect.
The style for the v-21 is
<style name="BorderlessImageButton" parent="AppTheme.BorderlessImageButton">
<item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
<item name="android:tint">#color/secondary_text</item>
</style>
The style that will be used for all other API's below v-21 is
<style name="BorderlessImageButton" parent="AppTheme.BorderlessImageButton"/>
<style name="AppTheme.BorderlessImageButton" parent="#android:style/Widget.ImageButton">
<item name="android:tint">#color/secondary_text</item>
<item name="android:background">#color/borderless_button_background</item>
</style>
Here is my xml resource
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="#id/date_picker"
android:background="#null"
android:padding="10dp"
android:src="#drawable/ic_today_white_24dp"
android:theme="#style/BorderlessImageButton" />
If I run this on a device that has v-21 or v-22, the button doesn't visually react to my touch as I would expect using the ?android:attr/selectableItemBackgroundBorderless. Also, on any device below v-21, the button still doesn't react to the selector resource I have set up for it.
res/color/borderless_button_background.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#color/accent" />
<item android:color="#color/transparent"/>
</selector>
Please help me get my button to react properly to touch based on which API the user has on their device.
Thanks
You need to apply your style with
style="#style/BorderlessImageButton"
The attribute android:theme is used for activities, see this.
UPDATE
Since Android 5.0, or using AppCompat 22.1.0+ (api 11+), you can also use a ThemeOverlay and use android:theme on single views. You can read about this technique here. Thanks to Ian for this.
I am having trouble changing the style of a Switch view in my project and can't figure out what I am doing wrong or missing... My project uses holo everywhere.
I can't change the text, the thumb or the track. I've tried applying android:thumb and android:track drawables directly from the xml but nothing changes. Not even the android:textOff and android:textOn have any effect.
I found a great post on how to customise the android Switch view style and looked through all the code but couldn't find anything I was doing wrong:
http://custom-android-dn.blogspot.co.uk/2013/01/how-to-use-and-custom-switch-in-android.html
Really not sure what else to try.
Here is the xml code:
<Switch
android:id="#+id/home_availability_switch"
style="#style/MySwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:enabled="true"
android:focusable="true"
android:textOff="Free"
android:textOn="Busy" />
Here is the style:
<style name="MySwitch" parent="#style/Holo.Switch.Light">
<item name="android:thumb">#drawable/selector_availability_switch_thumb</item>
<item name="android:track">#drawable/selector_availability_switch_background</item>
</style>
Here is the thumb selector
(these are default system drawables. i have tried with different drawables):
<item android:drawable="#drawable/switch_thumb_pressed_holo_light" android:state_pressed="true"/>
<item android:drawable="#drawable/switch_thumb_activated_holo_light" android:state_checked="true"/>
<item android:drawable="#drawable/switch_thumb_disabled_holo_light" android:state_enabled="false"/>
<item android:drawable="#drawable/switch_thumb_holo_dark"/>
Here is the track selector
(these are default system drawables. i have tried with different drawables):
<item android:drawable="#drawable/switch_bg_disabled_holo_dark" android:state_enabled="false"/>
<item android:drawable="#drawable/switch_bg_focused_holo_dark" android:state_focused="true"/>
<item android:drawable="#drawable/switch_bg_holo_dark"/>
I also found this post How can I style an Android Switch? and follow the instructions but had no luck.
Any one else had a similar experience when using Holo Everywhere?
You need to define the switch like this. Need the whole package name in there for it to work.
<org.holoeverywhere.widget.Switch
android:id="#+id/lockSwitch"
style="?switchStyleOld"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestSwitch" />
Hope this helps.
I am adding an actionbar to a test app I'm writing, and I see questions throughout stackoverflow about this, but nothing that has helped me at all. Based off of this guide:
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html
I'm trying to change the select color for tabs that i'm using on my action bar. The default is that faint blue color. Just as a test I did this:
<style name="CustomTab" parent="android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#000000</item>
</style>
That gives me a solid black tab completely, not the selector part. Can someone help better direct me here? I can't seem to find a good example anywhere.
First you have to define a selector xml file then write this code there and replace your code with this
item name="android:background">#drawable/yourfilename</item>
and the selector xml
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:state_pressed="true"
android:drawable="#drawable/picture_selected" />
<item
android:state_focused="true"
android:drawable="#drawable/picture_selected" />
<item
android:drawable="#drawable/picture_unselected" />
</selector>
I'm creating a Optionsmenu, for that I use the Android Icon-Resource. But I can't access them, what am I doing wrong. What do I need to change?
Here's the Code of my menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/Videos"
android:icon="#android/drawable/ic_menu_view"
android:title="Videos" />
<item android:id="#+id/Bio"
android:icon="#android/drawable/ic_menu_friendlist"
android:title="Biographie" />
<item android:id="#+id/Support"
android:icon="#android/drawable/ic_menu_star"
android:title="Support" />
</menu>
thank you for the help in advance!
You are almost correct, when accessing framework resources you have to prefix the resource type with android: since you are using the android package here. Which means it should not be
android:icon="#android/drawable/ic_menu_view"
but
android:icon="#android:drawable/ic_menu_view"
instead for example (note the colon between android and drawable instead of a forward slash).
Also note that you can't access some resources, since they are not public, such as the ic_menu_star you are using here. You have to copy them to your projects drawable folders, which means you have to access them via a normal #drawable/ic_menu_star after doing that. See this question for reference.
try :
android:icon="#android:drawable/ic_menu_view"
instead of :
android:icon="#drawable/ic_menu_view"
Try this:
<item android:id="#+id/Videos"
android:icon="#drawable/ic_menu_view"
android:title="Videos" />
<item android:id="#+id/Bio"
android:icon="#drawable/ic_menu_friendlist"
android:title="Biographie" />
<item android:id="#+id/Support"
android:icon="#drawable/ic_menu_star"
android:title="Support" />
I think #android/drawable/ is incorrect. You should use instead #drawable/
You can see it: http://developer.android.com/guide/topics/ui/menus.html
Hope this helps...