Android Custom Styleable Properties

Source: Internet
Author: User

1. Definition

Defined in Attr.xml

<Resources>    <declare-styleablename= "Viewflow">        <attrname= "Sidebuffer"format= "integer" />    </declare-styleable>    <declare-styleablename= "Circleflowindicator">        <attrname= "Activecolor"format= "Color" />        <attrname= "Inactivecolor"format= "Color" />        <attrname= "radius"format= "Dimension" />        <attrname= "Spacing"format= "Dimension" />        <attrname= "Centered"format= "Boolean" />        <attrname= "FadeOut"format= "integer" />        <attrname= "Inactivetype">            <Flagname= "Stroke"value= "0" />            <Flagname= "Fill"value= "1" />        </attr>        <attrname= "Activetype">            <Flagname= "Stroke"value= "0" />            <Flagname= "Fill"value= "1" />        </attr>        <attrname= "Snap"format= "Boolean" />    </declare-styleable>        <declare-styleablename= "Titleflowindicator">        <attrname= "Titlepadding"format= "Dimension" />        <!--left/right padding of not active view titles. -        <attrname= "Clippadding"format= "Dimension" />        <attrname= "Selectedcolor"format= "Color" />        <attrname= "Selectedbold"format= "Boolean" />        <attrname= "Selectedsize"format= "Dimension" />        <attrname= "TextColor"format= "Color" />        <attrname= "TextSize"format= "Dimension" />        <attrname= "Footerlineheight"format= "Dimension" />        <attrname= "Footercolor"format= "Color" />        <attrname= "Footertriangleheight"format= "Dimension" />        <attrname= "Customtypeface"format= "string" />    </declare-styleable>    </Resources>

Related fields

Resources, Declare-styleable->attr (name, Format (Color,dimension,boolean,string,integer,)) or flag (name , value)

Use in 2.layout

<Framelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:app= "Http://schemas.android.com/apk/res/org.taptwo.android.widget.viewflow.example"android:orientation= "vertical"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent">    <Org.taptwo.android.widget.CircleFlowIndicatorandroid:padding= "10dip"Android:layout_height= "Wrap_content"Android:layout_width= "Wrap_content"Android:id= "@+id/viewflowindic"android:layout_gravity= "Center_horizontal"App:inactivetype= "Fill"App:fadeout= "+" />    <Org.taptwo.android.widget.ViewFlowAndroid:id= "@+id/viewflow"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"App:sidebuffer= "3"></Org.taptwo.android.widget.ViewFlow></Framelayout>

1.xmlns:app= "Http://schemas.android.com/apk/res/org.taptwo.android.widget.viewflow.example"

App for custom tag prefix path to Http://schemas.android.com/apk/res + resource path (package name)

2.app:inactivetype= "Fill" app:fadeout= "app:textcolor=" #FFFFFFFF "app:footertriangleheight=" 10DP "app: Customtypeface= "Fonts/antic.ttf"

As defined above footertriangleheight is dimension type Customtypeface is string type
Read in 3.view
    TypedArray a = Context.obtainstyledattributes (Attrs,                r.styleable.circleflowindicator);        Gets the active circle type, defaulting to "fill"        int activetype = A.getint (r.styleable.circleflowindicator_active Type,                Style_fill);                int activedefaultcolor = 0xFFFFFFFF;                Get a custom active color if there is one        int activecolor = a                . GetColor (R.styleable.circleflowindicator_activec Olor,                        Activedefaultcolor);

such as 1.obtion TypedArray 2.getInt GetColor and so on

Android Custom Styleable Properties

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.