Issue
I want to have a Text-Button which can be highlighted when pressed and it will have an empty background. (Basically like a link in a browser)
I used a button for this.
The following code works as i entered it for the "background" attribute. If i enter it for textColor attribute, i get "android.content.res.Resources$NotFoundException:" for the "textbutton" resource (which i have tried adding it to both color and drawble directories)
<Button android:text="My Text" android:background="@drawable/textbutton" android:textColor="#FFFFFFFF" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button>
The following code does not work:
<Button android:text="My Text" android:background="#0000" android:textColor="@drawable/textbutton" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button>
(making it a color/, instead of a drawable does not work too)
This is the contents of textbutton.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><color android:color="#FFFFFFFF"></color></item>
<item android:state_focused="true"><color android:color="#FFFFFFFF"></color></item>
<item><color android:color="#FF33b5e5"></color></item>
</selector>
Solution
The problem was NOT defining "color" property inside "item" tag.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#FFFFFFFF"></item>
<item android:state_focused="true" android:color="#FFFFFFFF"></item>
<item android:color="#FF33b5e5"></item>
</selector>
Answered By - frankish
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.