One reason why Android selector is invalid

Source: Internet
Author: User
Problem reproduction:

When selector is used, it is expected that the button image will change color when you press the button. The Code is as follows:

<Button
Android: Id = "@ + ID/btn_match"
Style = "@ style/dashboardbutton"
Android: drawabletop = "@ drawable/btn_match"
Android: text = ""/>

The selector is written in
Btn_match.xml controls the status of buttons under various States.

However, the button does not change color during actual operation.

Cause:

First, this is not a problem caused by incorrect order of pressed, selected, and default;

The real reason is that there is an image named btn_match.png in the drawable folder of my project. The system first resolves btn_match in Android: drawabletop = "@ drawable/btn_match" to btn_match.png, rather than the expected btn_match.xml.

When you press Ctrl and move the mouse to "@ drawable/btn_match", there will be two prompt statements: the first is btn_match.png, and the second is btn_match.xml. the system selects btn_match.png as the priority.

Solution:

Delete btn_match.png or rename it.

Related Article

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.