MaterialAutoCompleteTextView dropdown selected item background color - android

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

Related

custom spinner with colored dropdown image

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

How to color a portion of a view in android?

Now I have this task where I should create a rating bar just like youtube in my app , and so my idea was to have a textview where I set its background to a color but then remove the color according to an equation I will make so it displays only a percentage of it... any idea how can I do this or where to look ?
The simplest way to do this would be to create a selector.xml. You would assign android:background="#drawable/selector". Your selector would decide which background color to show based on what percentage you have assigned.
This link explains how to use selectors with buttons. It should help to get you on the right track...http://developer.android.com/guide/topics/resources/color-list-resource.html
EDIT: You can still accomplish a custom progress bar by xml. It is very similar to the selector. Just think of it as many more selectors based on progress instead of state. Here is a nice example...Custom Drawable for ProgressBar/ProgressDialog
You can also look into xml animations. They are similar.

Default android.R.atrr. for ListView item background color

I know I can use the android.R.attr. for default values (like colors, styles, etc.)
Does anyone know which android.R.atrr. I need to use for the default ListView Item background color?
When I look at the available android.R.atrr. I see there is colorFocusedHighlight, colorLongPressedHighlight, colorMultiSelectHighlight and colorPressedHighlight, but not one for just the item that isn't pressed/focussed/etc.
It's actually a drawable, not a color like I mentioned in my comment.
http://developer.android.com/reference/android/R.drawable.html#list_selector_background

Android change the List view theme at runtime

Can anyone give me some idea or code if possible regarding how to change the Theme of Listview ( like the back ground color, text color, icons etc) by clicking a button for example at runtime?
I saw an example here android dynamically change style at runtime.
I want to know if something similar is possible for List Views?
Thank You.
For changing the Bg color, you can set it dynamically.
mListView.setBackgroundColor(mColor); //doc
For changing the design in your listView, you have to set some variables, then use them in your custom adapter. When you click, you change these variables and call the notifyDataSetChanged() method.
Hope this will help you.
If I understand your question correctly, you want to customize the look and feel of the rows (individually or all) dynamically. If so, using a custom adapter and overriding the getView(...) function will probably work for you.
A quick explanation is available at http://www.mkyong.com/android/android-listview-example/
Hope this helps.

ListViewItem background color

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.

Categories

Resources