I am working with custom spinner. I am struggle on this.
How can I get the spinner like this ?
Note : I have the red color image.
From API 21, you can use widget tinting feature, most widgets (spinner included) will follow your colorAccent.
For lower APIs, you can apply custom drawable. Check android-holor-colors for a quick generation of your widget drawable. In your case, check 'Spinner' or 'Colored Spinner'.
Try Custom adapters.
You can design how a row of your spinner looks like.
The link bellow will help you.
http://androidexample.com/Custom_Spinner_With_Image_And_Text_-_Android_Example/index.php?view=article_discription&aid=84&aaid=107
Related
I am using the MaterialAutoCompleteTextView component. I would like if possible to set a different background color for selected item.
This is the current UI:
I would like to achieve this:
Any idea how to solve it?
I asked in the github and the solution is update the material library and use the property MaterialAutoCompleteTextView.setSimpleItemSelectedColor() to achieve that.
(only available since 1.7.0-alpha02.)
https://github.com/material-components/material-components-android/issues/2754
My problem is straight-forward.
I have a default spinner in android API 19.
But i want to customize it to make it have a border and also a triangular shape at the end pointing at the bottom. (Like the spinner with old versions of android).
I have this spinner: http://androidopentutorials.com/wp/wp-content/uploads/2014/03/android-4-spinner.jpg?f9f065
But I want the spinner to be like this: http://lh4.ggpht.com/-DwIrYX29Rzg/TsPtjLkIkLI/AAAAAAAAAjs/m3GvtKmRDGo/firstLayout_thumb.png?imgmax=800
How can i customize the spinner?
I have searched for tutorials online but i got only those custom spinner with image and text together.
Have a look at this tutorial: http://www.mokasocial.com/2011/03/easily-create-a-default-custom-styled-spinner-android/
Basically, what you need is a 9-patch that you will use as a background of your Spinner.
The steps are fairly simple:
Get your 9-patches ready.
Create a <selector> that represents the stats of your Spinner by using these 9-patches.
Set the <selector> as the background for your Spinner.
The caveat to my approach is that you will have to set the background for every Spinner you use. If you want to 'do it once, use it everywhere', follow the tutorial approach where the author uses a custom theme.
when I show my custom listviewitem to the user, all the items and objects contained in each item have the color that I want,
but when scrooling and selecting ( with onListItemClick ), the items don't change the background color for the desired color
Sounds like you need to set the cache color hint. This blog post -- http://android-developers.blogspot.com/2009/01/why-is-my-list-black-android.html -- goes in to how to do that, and why you need to do it.
Try to add this to the onCreate method of your activity.
your_list_view.setCacheColorHint(0);
I had the same issue few days ago and it solved my problem. If you feel it is not what you need to do, then please post some code to have more details.
You will need to use selector for that. Check this http://android-codes-examples.blogspot.com/2011/03/customized-listview-items-selection.html
Read this note about CacheColorHints in the android reference guide:
http://developer.android.com/resources/articles/listview-backgrounds.html
it explains the concept behind it and why you need to set it to "#00000000" in your XML or 0 in your code.
Turns out, my view has a custom android:list<view>, and on my custom listview definition, i was using the android:background definition for each textview.
With this, I was not using the transparent or system defined color for background items on the listview. I removed this definition from my custom listview items definition, and the problem was solved.
Hai!
In my application i want to change the listView text color in android.
How can i achieve this.
any solution will be appreciated...
ListView uses some optimizations when displaying itself, so you have to take some care when changing colors: http://developer.android.com/resources/articles/listview-backgrounds.html
You'll need to use a custom Adapter to do this. This tutorial looks pretty good: custom list view
The default color of the text is white. Let's say if i want to change the color, then how can i do it? Any clue?
in the getView method, find your TextView and set the color via setTextColor().
If you want your color changed for you based on the state of the item ( selected/focused etc) create new color in my_color.xml and define your states - examples of stateful colors are in SDK in res folders.
I highly recommened writing your own theme for the list view and then setting it in the layouts xml file, this means that you can use the same style throughout your app
This is a good tutorial to start with
http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/
One thing you could do is use your own layout for the list items. This way you could set whatever color or any other layout in the items.
You couldn't use setTextColor(); in your ListAdapter ? I think you could