Android-set PullToRefresh pull-down refresh style and androidpull Parsing
Android-set PullToRefresh pull-down refresh Style
The following are custom style attributes of the open-source control PullToRefresh:
<? Xml version = "1.0" encoding = "UTF-8"?> <Resources> <declare-styleable name = "PullToRefresh"> <! -- A drawable to use as the background of the Refreshable View --> <! -- Set the background color of the entire refresh list --> <attr name = "ptrRefreshableViewBackground" format = "reference | color"/> <! -- A drawable to use as the background of the Header and Footer Loading Views --> <! -- Set the background color of the drop-down Header or Footer --> <attr name = "ptrHeaderBackground" format = "reference | color"/> <! -- Text Color of the Header and Footer Loading Views --> <! -- Used to set the text color of the Header and Footer --> <attr name = "ptrHeaderTextColor" format = "reference | color"/> <! -- Text Color of the Header and Footer Loading Views Sub Header --> <! -- Used to set the color of the last refresh time in the Header and Footer --> <attr name = "ptrHeaderSubTextColor" format = "reference | color"/> <! -- Mode of Pull-to-Refresh that shoshould be used --> <attr name = "ptrMode"> <flag name = "disabled" value = "0x0"/> <! -- Disable pull-down refresh --> <flag name = "pullFromStart" value = "0x1"/> <! -- Only pull-down refresh is supported --> <flag name = "pullFromEnd" value = "0x2"/> <! -- Only pull-up refresh is supported --> <flag name = "both" value = "0x3"/> <! -- Supports both pull-up and pull-down refreshes --> <flag name = "manualOnly" value = "0x4"/> <! -- Only manual triggering is allowed --> <! -- These last two are depreacted --> <flag name = "pullDownFromTop" value = "0x1"/> <flag name = "pullUpFromBottom" value = "0x2"/> </attr> <! -- Whether the Indicator overlay (s) shocould be used --> <! -- If this parameter is set to true, an icon is displayed in mPullRefreshListView, which is in the upper right and lower right corner. It is interesting --> <attr name = "ptrShowIndicator" format = "reference | boolean"/> <! -- Drawable to use as Loading Indicator. Changes both Header and Footer. --> <! -- Change the icon at the header and bottom --> <attr name = "ptrDrawable" format = "reference"/> <! -- Drawable to use as Loading Indicator in the Header View. Overrides value set in ptrDrawable. --> <! -- Icon in the header View --> <attr name = "ptrDrawableStart" format = "reference"/> <! -- Drawable to use as Loading Indicator in the Footer View. Overrides value set in ptrDrawable. --> <! -- Icon of the bottom view --> <attr name = "ptrDrawableEnd" format = "reference"/> <! -- Whether Android's built-in Over Scroll shoshould be utilised for Pull-to-Refresh. --> <attr name = "ptrOverScroll" format = "reference | boolean"/> <! -- Base text color, typeface, size, and style for Header and Footer Loading Views --> <! -- Set the font type and color of the headers or Footer. --> <attr name = "ptrHeaderTextAppearance" format = "reference"/> <! -- Base text color, typeface, size, and style for Header and Footer Loading Views Sub Header --> <attr name = "ptrSubHeaderTextAppearance" format = "reference"/> <! -- Style of Animation shocould be used displayed when pulling. --> <attr name = "ptrAnimationStyle"> <flag name = "rotate" value = "0x0"/> <! -- Flip (flip animation), rotate (rotation animation) --> <flag name = "flip" value = "0x1"/> </attr> <! -- Whether the user can scroll while the View is Refreshing --> <! -- Whether to allow ListView or GridView scrolling when refreshing --> <attr name = "ptrScrollingWhileRefreshingEnabled" format = "reference | boolean"/> <! -- Whether PullToRefreshListView has it's extras enabled. this allows the user to be able to scroll while refreshing, and behaves better. it acheives this by adding Header and/or Footer Views to the ListView. --> <! -- Determines how the Header and Footer are added to the mPullRefreshListView. true indicates that the Header is added to the headView, the refresh header will scroll together --> <attr name = "ptrListViewExtrasEnabled" format = "reference | boolean"/> <! -- Whether the Drawable shocould be continually rotated as you pull. this only takes effect when using the 'rotate' Animation Style. --> <attr name = "ptrRotateDrawableWhilePulling" format = "reference | boolean"/> <! -- Below here are depreceated. do not use. --> <attr name = "ptrAdapterViewBackground" format = "reference | color"/> <attr name = "ptrDrawableTop" format = "reference"/> <attr name = "ptrDrawableBottom" format = "reference"/> </declare-styleable> </resources>
You can set custom styles in the layout file as follows:
<com.handmark.pulltorefresh.libaray xmlns:ptr="http://schemas.android.com/apk/res-auto" android:id="@+id/lv" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:cacheColorHint="#00000000" android:divider="@drawable/border" android:fadingEdge="none" android:fadingEdgeLength="0dip" android:scrollbars="none" android:scrollingCache="true" ptr:ptrDrawable="@drawable/infzm_logo" />
Note: The namespace should be declared: xmlns: ptr = http://schemas.android.com/apk/res-auto
Use custom attributes: ptr: ptrDrawable = "@ drawable/logo"
The usage of other attributes is similar.