Images that can't be displayed under Android 2.1/2.2/2.3 and how to solve them.

Source: Internet
Author: User

These days in writing Android apps, there's something really weird about this:

A picture resource is set on the layout as a background and can be displayed in the Eclipse's layout design interface, but the picture is completely out of view when the emulator is started;

But the truth is far from simple. Later I put the application package to a few friends of my test, found that the picture is not displayed.

Among them, my application support version is 2.1, the simulator version is 2.1, my machine version is 4.0, two friend's machine is 2.1 and 2.3 respectively. So I guess the picture is not compatible with 2.1 and 2.3, so we set up a separate project to test the diagram, and it turns out to be a show.

Why this diagram is not displayed on my application, can be displayed on the test application, and it is related to the version ...

After a toss and a variety of hypotheses and experiments found a solution:

The name of the diagram is the beginning of a, so in the first, Android automatically generates the R-class resource index, which is indexed to 0x7f040000, with 0 wood behind it! I found that as long as the index is 0x7f040000 picture resources, in my application can not be displayed, so I throw in a useless picture named Aaa.png let it in the first occupy 0x7f040000 this index, then, everything is normal.

Question: Although the problem has been solved, why is the same picture resource index in the test project 0x7f040000 can also be displayed? I guess it might be that my app uses some other XML-defined drawable resource conflicts, maybe Android bugs, but how exactly this problem is generated is still unclear.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

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.