Textview selector gets focus in linearlayout

Source: Internet
Author: User

It is usually necessary to modify the text color when textview is selected, which is always ineffective. The following methods can be implemented:

<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">    <item android:state_pressed="true" android:color="#FF111111"/>    <!-- pressed -->    <item android:state_focused="true" android:color="#FF222222"/>    <!-- focused -->    <item android:state_selected="true" android:color="#FF333333"/>    <!-- selected -->    <item android:state_active="true" android:color="#FF444444"/>    <!-- active -->    <item android:state_checkable="true" android:color="#FF555555"/>    <!-- checkable -->    <item android:state_checked="true" android:color="#FF666666"/>    <!-- checked -->    <item android:state_enabled="true" android:color="#FF777777"/>    <!-- enabled -->    <item android:state_window_focused="true" android:color="#FF888888"/>    <!-- window_focused --></selector>

In textview, add the selector: Android: textcolor = "@ drawable/text_wbcolor_selector"

1. Click events can be added and set in the background, whether or not click events:

Textview. setonclicklistener (null );

2. Add Android: clickable = "true" Android: focusable = "true" to the parent control, and add Android: duplicateparentstate = "true" sub-control to obtain the Click Event of the parent control.

3. Set colorstatelist in the background code. This class can also be used.

4. Switch the color by clicking the event (a little effort ).

Textview selector gets focus in linearlayout

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.