<span id="Label3"></p><p><p>When you write code today, you need to set a TextView click effect, Press Status and normal status two icon, while the click Area background in the press state is also different. When implemented, the TextView will be placed in relativelayout, relativelayout as the click area, Set the background effect of the click, TextView display different icon images when Clicked.<br>The layout file is as follows</p></p><pre><pre><code><RelativeLayout android:id="@+id/dele_layout" android:layout_width="math_parent" android:layout_height="48dp" android:background="@drawable/setting_delete_selector" > <TextView android:id="@+id/delete_move_notice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/webview_move_setting_close" /></RelativeLayout></code></pre></pre><p><p>Click the area background setting_delete_selector.xml file below</p></p><pre><pre><code><selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@color/setting_move_webview_bg"></item><item android:drawable="@color/setting_move_action_setting__close_press_bg" android:state_pressed="true"></item></code></pre></pre><p><p></p></p><p><p>Textview's Selector File</p></p><pre><pre><code><selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@drawable/pop_ico_delete_normal"></item><item android:drawable="@drawable/pop_ico_delete_press" android:state_pressed="true"></item></code></pre></pre><p><p></p></p><p><p>The color values used in <strong>selector.xml</strong> are defined in Color.xml. There's no more sticking out here.</p></p><p><p>Such code, kill all have no effect, no effect, no Effect. Important thing to say three times!!!</p></p><p><p>laboriously, Find all the code, rewrite the demo test, and finally find out why is</p></p><em>press <em>status to be placed on the first line of selector</em></em><p><p>Modify the two files as Follows:</p></p><pre><pre><code><selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@drawable/pop_ico_delete_press" android:state_pressed="true"></item><item android:drawable="@drawable/pop_ico_delete_normal"></item></selector></code></pre></pre><p><p>In this way, the effect will be ~</p></p> <p style="font-size:12px;"><p style="font-size:12px;">Copyright Notice: This article for Bo Master original article, without Bo Master permission not Reproduced.</p></p> <p><p>Android drawable selector settings are invalid</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service