Change all Color on Text Controller - android

I need change all color for EditText, I tried all my information
ex:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_window_focused="false"
android:state_enabled="true"
android:drawable="#color/colorJust" />
<item
android:state_window_focused="false"
android:state_enabled="false"
android:drawable="#color/colorJust" />
<item
android:state_pressed="true"
android:drawable="#color/colorJust" />
<item
android:state_enabled="true"
android:state_focused="true"
android:drawable="#color/colorJust" />
<item
android:state_enabled="true"
android:drawable="#color/colorJust" />
<item
android:state_focused="true"
android:drawable="#color/colorJust" />
<item
android:drawable="#color/colorJust" />
</selector>
with: android:background="#drawable/edittext_bg"
But result is not good, the pink color is always on top when click and select text
I need to remove this PINK color i hate it!

The colour of the checkboxes, cursor, etc. is determined by your accent see here
Try adding this to your styles:
<item name="android:colorAccent">#color/colorJust</item>

you can choose android:textCursorDrawable="#null", the cursor will use android:textColor color then. or to remove cursor from edittext you can do something like android:cursorVisible="false"

Related

Change the tint of the compoundDrawable right of EditText based on focus states

I have been trying to figure out how to change the tint of a compoundDrawable of an EditText for some time with no success. I am using the EditText as a button and would like to change the color of the drawable right like the EditText underline color. How do I add a drawable state to the compoundDrawables?
I would like to tint the drawable like the underline tint when clicked.
Here is my styles.
<style name="EditTextDropdown" parent="#android:style/Widget.EditText">
<item name="android:clickable">true</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:focusable">false</item>
<item name="android:focusableInTouchMode">true</item>
<item name="android:singleLine">true</item>
<item name="android:cursorVisible">false</item>
<item name="android:layout_marginLeft">16dp</item>
<item name="android:layout_marginRight">16dp</item>
<item name="android:drawableRight">#drawable/ic_drop_down_arrow_24dp</item>
</style>
EditText
<EditText
android:id="#+id/phone"
style="#style/EditTextDropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Add phone" />
Here is what it looks like normal
Here is what it looks like when pressed
you can directly override the appearance of the EditText by re-assigning it's attributes in the style of the Theme you are using in your app.
given code overrides the EditText Appearance.
<item name="android:editTextBackground">
#drawable/myenglishviolettheme_edit_text_holo_light
</item>
and the file in drawable is something like this myenglishviolettheme_edit_text_holo_light.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true" android:drawable="#drawable/myenglishviolettheme_textfield_default_holo_light" />
<item android:state_window_focused="false" android:state_enabled="false" android:drawable="#drawable/myenglishviolettheme_textfield_disabled_holo_light" />
<item android:state_enabled="true" android:state_focused="true" android:drawable="#drawable/myenglishviolettheme_textfield_activated_holo_light" />
<item android:state_enabled="true" android:state_activated="true" android:drawable="#drawable/myenglishviolettheme_textfield_focused_holo_light" />
<item android:state_enabled="true" android:drawable="#drawable/myenglishviolettheme_textfield_default_holo_light" />
<item android:state_focused="true" android:drawable="#drawable/myenglishviolettheme_textfield_disabled_focused_holo_light" />
<item android:drawable="#drawable/myenglishviolettheme_textfield_disabled_holo_light" />
</selector>
You may want to change the drawable resources to match your requirement

Android Button selector not working properly

I am using the following selector to change the color of a button
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="#color/darkgray" />
<item android:state_enabled="true" android:state_pressed="true" android:drawable="#color/background_red_down" />
<item android:drawable="#color/background_red" />
</selector>
I am getting the red color for the button but that's it. I am not getting the gray disabled color, the button is indeed disabled as it is unclickable. I am also not getting the red_down color once I click.
What have I missed?
Thanks
in your color.xml
replace this
<color name="background_red">#9A9484</color>
to
<drawable name="background_red">#9A9484</drawable>
"#9A9484 = your background color"
This is code from my button selector. Modify it's values and it should work for you.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
android:drawable="#drawable/redtheme_btn_default_normal_holo_light" />
<item android:state_window_focused="false" android:state_enabled="false"
android:drawable="#drawable/redtheme_btn_default_disabled_holo_light" />
<item android:state_pressed="true"
android:drawable="#drawable/redtheme_btn_default_pressed_holo_light" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="#drawable/redtheme_btn_default_focused_holo_light" />
<item android:state_enabled="true"
android:drawable="#drawable/redtheme_btn_default_normal_holo_light" />
<item android:state_focused="true"
android:drawable="#drawable/redtheme_btn_default_disabled_focused_holo_light" />
<item
android:drawable="#drawable/redtheme_btn_default_disabled_holo_light" />
</selector>

Highlight mysterious behaviour in ListView

I have set a custom list selector for a Simple ListView but when I select an item, the whole ListView turns blue. I don't understand where the problem is.
This is my ListView:
<ListView android:id="#+id/TopListView" android:layout_width="fill_parent"
android:listSelector="#drawable/regular_selector"
android:layout_height="wrap_content">
</ListView>
and it's the regular_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="#color/transparent" />
<item android:state_pressed="true"
android:drawable="#color/blue" />
<item android:state_focused="true"
android:drawable="#color/blue" />
</selector>
I was having the same issue of the whole list view highlighting, when using a color as the background. Curiously this only happened below api 11.
Solution was to use a solid shape drawable to wrap the colour:
list_selector_shaped_background_press.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#color/list_selector_pressed"/>
</shape>
List_selector_background.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_window_focused="false"
android:drawable="#android:color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false"
android:state_pressed="true"
android:drawable="#drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_enabled="false"
android:drawable="#drawable/list_selector_background_disabled" />
<!-- this has to be in a shaped drawable otherwise the whole list is highlighted selects -->
<item android:state_focused="true" android:state_pressed="true"
android:drawable="#drawable/list_selector_shaped_background_pressed" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="#drawable/list_selector_shaped_background_pressed" />
<item android:state_focused="true"
android:drawable="#drawable/list_selector_background_focus" />
</selector>
I guess it is the usual problem. You have to set this in your listview:
android:cacheColorHint="#00000000"
The goal is to disable an optimization that the framework does for improving drawing performance during scrolling operations.
When I set the regular_selector.xml as listview item background it work!

How to disable the default Button color changing property on onClick

For the default android button, when I click on it, its color is changed to orange for a few seconds (for notifying the user the button is clicked). Anyway, I don't want this property. I don't want to change my button color. How can I disable this property?
Have a look on how button is styled by Android:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
android:drawable="#drawable/btn_default_normal" />
<item android:state_window_focused="false" android:state_enabled="false"
android:drawable="#drawable/btn_default_normal_disable" />
<item android:state_pressed="true"
android:drawable="#drawable/btn_default_pressed" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="#drawable/btn_default_selected" />
<item android:state_enabled="true"
android:drawable="#drawable/btn_default_normal" />
<item android:state_focused="true"
android:drawable="#drawable/btn_default_normal_disable_focused" />
<item
android:drawable="#drawable/btn_default_normal_disable" />
</selector>
To style your button with Android's themes images resources, just create your own selector by copying the Android's one and replace all #drawable/btn_default_* by #android:drawable/btn_default_normal in items tag (and just remove items you don't want). For example :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:drawable="#android:drawable/btn_default_normal" />
</selector>
Then, apply this drawable selector as a android:background of your button.
Hope it helps.
(If you want, I can also provide an example of applying this background easily to all your buttons, just ask.)

Remove highlight effect from EditText

I want to remove the orange highlight around the EditText. This highlight doesn't match my UI and I really want to get rid of it.
Any ideas?
EditText uses selector for it's background.
From android source code:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
android:drawable="#drawable/textfield_default" />
<item android:state_window_focused="false" android:state_enabled="false"
android:drawable="#drawable/textfield_disabled" />
<item android:state_pressed="true" android:drawable="#drawable/textfield_pressed" />
<item android:state_enabled="true" android:state_focused="true" android:drawable="#drawable/textfield_selected" />
<item android:state_enabled="true" android:drawable="#drawable/textfield_default" />
<item android:state_focused="true" android:drawable="#drawable/textfield_disabled_selected" />
<item android:drawable="#drawable/textfield_disabled" />
</selector>
You have to create you own selector where you can use your own drawables for pressed and selected state. You can read more about selectors here

Categories

Resources