मैं एंड्रॉइड क्विज़ बना रहा हूं और जब मैं क्लिक करता हूं तो मैं बटन को हाइलाइट करना चाहता हूं लेकिन जब उपयोगकर्ता बटन को जाने देता है तो यह मूल रंग में बदल जाता है। आप देखते हैं कि मैंने बटन की पृष्ठभूमि सेट की है ताकि बटन गोल किए जा सकें। मैंने इसे खींचने में सेट कर दिया है।दबाए जाने पर बटन को हाइलाइट कैसे करें?
<Button
android:id="@+id/btn1"
android:background="@drawable/roundedbutton"
android:textColor="#ffffff"
android:textStyle="italic"
android:layout_width="225sp"
android:layout_marginTop="23sp"
android:layout_height="38sp"
android:layout_alignLeft="@+id/btn2"
android:layout_below="@+id/textView1"
android:text="Button" />
roundedbutton.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#848482"/> <!-- this one is ths color of the Rounded Button -->
<corners
android:bottomRightRadius="6.5dp"
android:bottomLeftRadius="6.5dp"
android:topLeftRadius="6.5dp"
android:topRightRadius="6.5dp"/>
</shape>
एक सरल समाधान विश्वास से एक के लिए और अधिक पूर्ण के साथ इसी तरह एक रंग फिल्टर का उपयोग कर रघुनाथन में से एक के रूप में टच लिस्टनर समाधान विवरण: http://stackoverflow.com/a/14278790/891479 यह स्पर्श पर रंग फ़िल्टर को संशोधित करने पर एक ऑन टचलिस्टर बनाता है। –