android - How to change rectangle colour when user touches it -
i place rectangle on android screen placing drawable background relativelayout. following how achieve it.
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white"> <relativelayout android:layout_width="200dp" android:layout_height="150dp" android:background="@drawable/welcome_rectangle" android:id="@+id/rectangular_orange" android:layout_centerinparent="true"></relativelayout> </relativelayout> the following xml drawable welcome_rectangle.
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/green_welcome_rectangle" /> <item android:drawable="@drawable/orange_welcome_rectangle" /> </selector> i want colour of rectangle change when user touches it. hasn't been achieved selector written. how can change selector code can want?
Comments
Post a Comment