Android Official Development Tutorials explained (i)

Source: Internet
Author: User

Recently prepared to learn a system of Android development, here will not copy the original text, only for some difficult to understand the tutorial part of the explanation, I am just a rookie.

In the first chapter of the tutorial-the basics of getting started, the section explaining the Android theme will probably have the following code:

<!--location Res/values/themes.xml -<?XML version= "1.0" encoding= "Utf-8"?> <Resources>  <!--topics for programs or activities -   <stylename= "Customactionbartheme"Parent= "@style/theme.appcompat.light.darkactionbar">       <!--api_7+ -       <Itemname= "Actionbarstyle">@style/myactionbar</Item>       <!--api_11+ -       <Itemname= "Android:actionbarstyle">@style/myactionbar</Item>     </style>     <stylename= "Myactionbar"Parent= "@style/widget.appcompat.light.actionbar.solid.inverse">         <!--api_7+ -         <Itemname= "Background">@drawable/actionbar_background</Item>         <!--api_11+ -         <Itemname= "Android:background">@drawable/actionbar_background</Item>     </style></Resources>

This code is used to define your own style: change the background of the Actionbar, the problem here is that the api-7 and api-11 code is written in the same file, the result can not be compiled through eclipse, The solution is to divide this themes.xml into multiple files, and the project automatically generates VALUES-V7, Values-v11, VALUES-V14, Themes.xml can be divided into several different versions of the different values, different devices of different styles is probably the way to achieve it?

The original text on the StackOverflow:

EDIT : If you want to is able to style your ActionBar to look the same in all APIs levels, you need To create different folders for the selected API level and create new style.xml / themes.xml files in these folders. For example:

- res  -- values     -- styles.xml     APILEVEL 8+ -- values-v11     -- styles.xml     APILEVEL11+ -- values-v14     -- styles.xml     APILEVEL 14+

There is no specific description in the tutorial to add a resource: @drawable/actionbar_background, just add a 1x1 pixel image, background The default effect is to stretch.

Finish

Android Official Development Tutorials explained (i)

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.