android-selector

Android: can you have a ripple effect whose default state color is transparent?

两盒软妹~` 提交于 2019-12-18 12:47:53
问题 Something like the following, but it doesn't work. If I switch the drawable color to something like blue, it works. <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight"> <item android:drawable="@android:color/transparent"/> </ripple> 回答1: It's necessary to add a mask: <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight"> <item android:id="@android:id/mask"> <color android

Deselect selected item in ListView

对着背影说爱祢 提交于 2019-12-18 05:36:15
问题 I use a ListView in my layout like this: <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_gravity="center" android:layout_height="match_parent" android:layout_weight="0.7" android:layout_marginTop="5dp" android:orientation="vertical" android:layout_centerInParent="true" android:divider="@color/dark_grey" android:drawSelectorOnTop="false" android:focusable="true" android:layout_marginBottom="55dp" android:cacheColorHint="#00000000" android:listSelector="@color

Android customized button; changing text color

ⅰ亾dé卋堺 提交于 2019-12-17 01:34:13
问题 I made a button that changes the background drawable on different states, this way: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/btn_location_pressed" /> <!-- pressed --> <item android:state_focused="true" android:drawable="@drawable/btn_location_pressed"/> <!-- focused --> <item android:drawable="@drawable/btn_location"/> <!-- default --> The problem here is that I'm also trying to change the textColor as

Android customized button; changing text color

那年仲夏 提交于 2019-12-17 01:34:08
问题 I made a button that changes the background drawable on different states, this way: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/btn_location_pressed" /> <!-- pressed --> <item android:state_focused="true" android:drawable="@drawable/btn_location_pressed"/> <!-- focused --> <item android:drawable="@drawable/btn_location"/> <!-- default --> The problem here is that I'm also trying to change the textColor as

Navigation View's selectors behave incorrectly

社会主义新天地 提交于 2019-12-14 02:19:22
问题 I'm following this color scheme of Navigation View. I created 3 selectors, for background, text and icon. When I set the selectors, my navigation view looked like this: The problem is that no item is shown selected and if I press one item, all items' background color changes to gray. Icon never gets the primary color. Here is are the XMLs: <android.support.design.widget.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start"

Make button background transparent using selector

我的未来我决定 提交于 2019-12-13 15:56:47
问题 Here we go. I have a button that has a non-pressed state background as transparent. As soon as the button is pressed, the background is no longer transparent (see the pics). I use nine patch for all my images. This is my selector: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/starfighterstartbtndown" android:state_pressed="true"/> <item android:drawable="@drawable/starfighterstartbtn"/> </selector

Selector for button error “Valid XML document must have a root tag”

丶灬走出姿态 提交于 2019-12-13 05:24:35
问题 I have three image for Button , using png format. I have made a Selector as below: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <!-- pressed --> <item android:state_pressed="true" android:drawable="@drawable/press_pdgmap" /> <!-- hover --> <item android:state_focused="true" android:drawable="@drawable/hover_pdgmap2" /> <!-- default --> <item android:drawable="@drawable/hover_pdgmap" /> </selector> But red tag appear in line

change statelistdrawable text color android button

为君一笑 提交于 2019-12-12 12:27:36
问题 I'm developing android application I have a different background drawable and text color for each status of the button (pressed , normal) I have created statelistdrawable object to be able to add the background drawable , but my problem now is how to set the text color can any one help please ? 回答1: Button is a TextView and you can call button.setTextColor(someColorStateList) on a TextView. Here is how to do it programmatically: ColorStateList colorStateList = new ColorStateList( new int[][]{

Android: How to change android:fillcolor with selector in one Vector Drawable xml

≯℡__Kan透↙ 提交于 2019-12-12 07:27:29
问题 Tab Icons: My current method is to create two files (ic_list_selected_24dp.xml and ic_list_unselected_24dp.xml; they are basically the same but only the android:fillColor='Color HEX CODE' are different), and then create a selector (selector_tabitem_list.xml) to change the drawable color when the state is changed. // @drawable/selector_tabitem_list.xml <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android

How to change EditText background color when I enter text?

孤街浪徒 提交于 2019-12-12 06:39:02
问题 My EditText has some color, but when I enter some text it should change. Say it's grey, I started to enter and it's yellow. This EditText is also focused, so when this activity starts -- I already can enter the text. How I tried: <style name="LoginEnterField"> <item name="android:textColorHint">@color/black</item> <item name="android:textColor">@color/black</item> <item name="android:background">@drawable/selector_edittext</item> <item name="android:textSize">@dimen/general_text_size</item>