MultiAutoCompleteTextView suggestion separator color - android

I'm using MultiAutoCompleteTextView in my Android app. I need to customize the suggestion list of this control. I've tried this to customize the list separator color but this didn't worked for me. How can I update the default list divider color of MultiAutoCompleteTextView?

In addition to setting the divider color, you need to also set the dividerHeight property or it won't work. And the Popup used by the MultiAutoCompleteTextView is actually a ListView, so setting that is correct here.
Add this to your styles.xml file:
<style name="myStyle" parent="#android:style/THeme.Holo.Light"> <!-- or whatever style you inherit -->
<item name="android:dropDownListViewStyle">#style/DropDownListViewStyle</item>
</style>
<style name="DropDownListViewStyle" parent="android:style/Widget.ListView.DropDown">
<item name="android:divider">#android:color/holo_orange_dark</item>
<item name="android:dividerHeight">2px</item>
</style>
This will set the dividers in the MultiAutoCompleteTextView's Popup to orange.

You can set the divider color of the ListView showing your results. This is set with the divider attribute.
Like this: android:divider="#color/mycolor
As an alternative, you could also create a custom drawable using a ShapeDrawable, that contains it's own custom divider color, then you apply that drawable as the background to your list element.

Related

How to change to text colour of the Cut/Copy/Paste popup menu

I have the following in my styles.xml
<style name="dialog_style" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#ffaaaa00</item>
<item name="android:background">#ff444400</item>
<item name="android:textColorPrimary">#ffa25600</item>
</style>
(The horrible colours are for testing only!)
This gives the following
What I want is a dark/black background but when I do that, the text is unreadable.
Q: How do I change the text colour of "Cut", "Copy"...?
tia,
Kevin
I think it's a little bit better solution than user3247782's,
<style name="CustomAlertDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
...
<item name="android:popupBackground">#android:color/transparent</item>
</style>
You can change them by following style names:
<item name="colorAccent">#color/twoCuteSelectionHandlersColor</item>
<item name="android:textColorHighlight">#color/selectionColor</item>
Also you can set highlight color directly for pacific EditText using android:textColorHighlight attribute in xml layout or programmatically:
et.setHighlightColor(color);
For context menu you need create your own context menu. check this question for how disabling default context menu and implementing custom menu.
This isn't really an answer. The black-on-black edit menu is only generated from an EditText contained in an AlertDialog. The same code in a Fragment gives black-on-white.
So I "solved" my problem by converting the AlertDialog into a Fragment.
The original question, though, is still unanswered.
Alert Dialog and Popup Menu generaly take the color of #ColorAccent as the background. So try changing the colorAccent or just inflate a custom xml with the specifications you want.
Just change the parent of it from Theme.Material.Light to Theme.Material .
It will make the text white, there.
I fixed it by setting a background color with opacity in the style of the alertdialog
In styles.xml
<style name="AppCompatAlertDialogStyle">
...
<item name="android:background">#color/black_overlay</item>
...
</style>
In colors.xml
<color name="black_overlay">#66000000</color>
If you use MaterialAlertDialogBuilder then you can define background color through colorSurface attribute.
Then in styles you can just set background to transparent.
android:background="#android:color/transparent"
Dialog will use the one define in colorSurface and "copy/paste" will use default system colors (e.g. white).

Android ActionMode styling, cannot set menu item colour

I am trying to set the text colour for all the text inside a ActionMode in android. I have found ways to change TitleTextColor and SubTitleTextColor but I cannot find a way to style the actual non-collapsed menu item text color.
I am using the android.support.v7.widget.toolbar using the statSupportActionMode(ActionMode.Callback) to display the action mode.
Thanks in advance,
Thomas.
<style name="ThemeName" parent="#style/Theme.Sherlock.Light">
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>
I used the iconTint attribute to style the menu items. Grab the xml file you use to inflate the menu then add the following attribute for each menu items that you want to style.
android:iconTint="#fff"
The above line of code will render the icons white. It's better to use your theme's color in styling.

android custom theme divider color for listview

I have designed a custom theme for the activity.Everything seems to be applying fine to the views except divider color for listview.(android:dividercolor attribute).
I applied it along with android:dividerheight attribute as suggested in other threads.divider height also applied correctly.
But when i apply divider color through activity xml file for the specific listview,custom color was applied correctly.
Can't we apply custom divider color from custom theme?
Instead of android:dividercolor, use android:listDivider.
<style name="MyAppTheme" parent="Some.Base.Theme">
<item name="android:listDivider">#color/my_divider_color</item>
<item name="android:dividerHeight">4dp</item>
</style>

2 Spinner with different style in same project

Surfing the web I've found this site which generates Android custom themes. I've used it to create my personal theme: it inherits from Android:Widget.Holo (should be the dark one with white text) and some fancy widget witha a custom color.
Because the theme inherits from Android:Widget.Holo, I have dark background and white text; but in some activity i need the opposite: white background with dark text.
When it comes to change the text color of most item i can do it easily using android:textColor="#android:color/black", but when i try to use it on spinner item it does nothing.
I've tried to create a new style only for spinner items, but i canno't apply it...
This is the first style generated (white text on black background):
<style name="SpinnerAppTheme" parent="android:Widget.Holo.Spinner">
<item name="android:background">#drawable/apptheme_spinner_background_holo_dark</item>
<item name="android:dropDownSelector">#drawable/apptheme_list_selector_holo_dark</item>
</style>
And this is the second I've generated (the opposite, back text on white background):
<style name="SpinnerDarkTextAppTheme" parent="android:Widget.Holo.Light.Spinner">
<item name="android:background">#drawable/apptheme_spinner_background_holo_light</item>
<item name="android:dropDownSelector">#drawable/apptheme_list_selector_holo_light</item>
<item name="android:textColor">#android:color/black</item>
</style>
But when I use style="#style/SpinnerDarkTextAppTheme nothing happens.
How can I do to have 2 different styles (obviously working at the same time) for my spinners?
SOLVED using this piece of code.
You can create two themes in the XML and switch between them before you set the content view:
https://stackoverflow.com/a/6390025/2219600
Another approach:
https://stackoverflow.com/a/16101936/2219600

What property controls Spinner dropdown background?

I have a custom theme created with this generator. It has a custom style for Spinners which I don't like. I want to change the background drawable but I can't seem to figure out which property controls this.
This is what the themed version looks like
And here is what it will look like when using the Holo.Light theme.
Notice the dark gray lines around the dropdown list in the first (themed) image. This is what I want to get rid of. What property controls this? I want them to match the default.
Also, what controls the vertical aligment of the dropdown list? As you can see, it is overlapping with the Spinner in the first image (the line under it isn't visible as it is in the second image).
The attribute you want is android:popupBackground on the Spinner element.
If you look closely, the holo popup also overlaps the spinner some, but there is a bunch of padding for the drop shadow, so it looks good.
However, you can use android:dropDownVerticalOffset on the Spinner element to adjust it.
We came across the same issue. It has to do with the Android Holo theme generator.
Here are the lines that you should remove from your Theme.xml file...
<item name="android:spinnerStyle">#style/SpinnerCustom</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerDropDownItemCustom</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Custom</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Custom</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Custom</item>
...by removing these, we now have the standard Holo.Light theme on the spinner dropdowns.
You need to change the parent of spinnertheme to android:Widget.Holo.Light.Spinner
<style name="SpinnerTHEME" parent="android:Widget.Holo.Light.Spinner">
<style name="spinner_style" parent="android:Widget.Holo.Light.Spinner">
<item name="android:paddingLeft">#dimen/ten_dp</item>
<item name="android:paddingRight">#dimen/ten_dp</item>
</style>

Categories

Resources