Android Development Learning Note-Custom TextView property templates

Source: Internet
Author: User

If you have many controls in your project that use the same style, you can set the style to the system for convenience, which is a lot easier to use.

Here's how to customize the style template.

1. Add the style content you want to set in the Style.xml file

<Resources>    <!--Base application theme, dependent on API level.    This theme are replaced by Appbasetheme from Res/values-vxx/styles.xml on newer devices.  -    <stylename= "Appbasetheme"Parent= "Theme.AppCompat.Light">        <!--Theme customizations available in newer API levels can go in res/values-vxx/styles.xml, while C        Ustomizations related to Backward-compatibility can go.  -    </style>    <!--application theme. -    <stylename= "Apptheme"Parent= "Appbasetheme">        <Itemname= "Android:windownotitle">True</Item>        <!--All customizations, that is, specific to a particular api-level can go. -    </style>    <stylename= "Text_content">        <Itemname= "Android:layout_width">Match_parent</Item>        <Itemname= "Android:layout_height">55dp</Item>        <Itemname= "Android:layout_marginleft">5dp</Item>        <Itemname= "Android:layout_margintop">5dp</Item>        <!--Custom TextView Styles -    </style></Resources>

2. Refer to the front end

<TextView      android:id= "@+id/baom1"      style= "@style/text_content"      android: Gravity= "center_vertical"      android:drawableleft= "@android:d rawable/star_big_on"       Android:text= "baojing"/>

3. Description:

In XML, name is a reference, item is the property name, and the corresponding value.

Android Development Learning Note-Custom TextView property templates

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.