java - Android change text color on click -
i changed actiondown , actionup colors match original color , text/button goes transparent.
my style script:
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="menufont"> <item name="android:textsize">20sp</item> <item name="android:textcolor">#cdcdcd</item> <item name="android:textstyle">normal</item> <item name="android:clickable">true</item> <item name="android:layout_weight">1</item> <item name="android:gravity">left|center</item> <item name="android:paddingleft">35dp</item> <item name="android:layout_width">175dp</item> <item name="android:layout_height">fill_parent</item> </style> original working script:
package com.pxr.tutorial.menu; import android.view.motionevent; import android.view.view; import android.widget.textview; public class customtouchlistener implements view.ontouchlistener { public boolean ontouch(view view, motionevent motionevent) { switch(motionevent.getaction()){ case motionevent.action_down: ((textview) view).settextcolor(0xff6a5acd); break; case motionevent.action_cancel: case motionevent.action_up: ((textview) view).settextcolor(0xffffff00); break; } return false; } } new script:
package com.synamegames.orbs; import android.view.motionevent; import android.view.view; import android.widget.textview; public class customtouchlistener implements view.ontouchlistener { public boolean ontouch(view view, motionevent motionevent) { switch(motionevent.getaction()){ case motionevent.action_down: ((textview) view).settextcolor(0x4f4f4f); break; case motionevent.action_cancel: case motionevent.action_up: ((textview) view).settextcolor(0xcdcdcd); break; } return false; } } what did change hex codes match original text color. once did text became transparent when clicked. did wrong?
use 0xff4f4f4f instead of 0x4f4f4f. , 0xffcdcdcd instead of 0xcdcdcd.
00..ff alpha value stands transparency.
Comments
Post a Comment