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