pulltorefresh(二)的自定義屬性介紹、attrs文件介紹

在上面一章,咱們簡介了PullToRefresh的使用了,咱們都知道了,他是一個自定義的控件,基本上每一個自定義控件的都會有本身的屬性,咱們這章介紹下他的有哪些屬性,全部的自定義控件的屬性,咱們須要如今res/values/attrs.xml去聲明下,我介紹下,這個自定義控件有哪些屬性react

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <declare-styleable name="PullToRefresh">
        <!-- 設置刷新列表的背景色 -->
        <attr name="ptrRefreshableViewBackground" format="reference|color" />
        <!-- 設置下拉Header或者上拉Footer的背景色 -->
        <attr name="ptrHeaderBackground" format="reference|color" />
        <!-- 用於設置Header與Footer中文本的顏色 -->
        <attr name="ptrHeaderTextColor" format="reference|color" />
        <!-- 用於設置Header與Footer中上次刷新時間文本的顏色 -->
        <attr name="ptrHeaderSubTextColor" format="reference|color" />
        <!-- 刷新模式 -->
        <attr name="ptrMode">
            <flag name="disabled" value="0x0" /> <!-- 禁用下拉刷新 -->
            <flag name="pullFromStart" value="0x1" /> <!-- 僅支持下拉刷新 -->
            <flag name="pullFromEnd" value="0x2" /> <!-- 僅支持上拉刷新 -->
            <flag name="both" value="0x3" /> <!-- 上拉刷新和下拉刷新都支持 -->
            <flag name="manualOnly" value="0x4" /> <!-- 只容許手動觸發 -->
            <!-- These last two are depreacted -->
            <flag name="pullDownFromTop" value="0x1" />
            <flag name="pullUpFromBottom" value="0x2" />
        </attr>
        <!-- 若是爲true會在mPullRefreshListView中出現icon,右上角和右下角,挺有意思的 -->
        <attr name="ptrShowIndicator" format="reference|boolean" />
        <!-- 同時改變頭部和底部的刷新圖標 -->
        <attr name="ptrDrawable" format="reference" />
        <!-- 頭部視圖的刷新圖標 -->
        <attr name="ptrDrawableStart" format="reference" />
        <!-- 底部視圖的刷新圖標 -->
        <attr name="ptrDrawableEnd" format="reference" />
        <attr name="ptrOverScroll" format="reference|boolean" />
        <!-- 分別設置拉Header或者上拉Footer中字體的類型顏色等等 -->
        <attr name="ptrHeaderTextAppearance" format="reference" />
        <attr name="ptrSubHeaderTextAppearance" format="reference" />
        <!-- flip(翻轉動畫), rotate(旋轉動畫) -->
        <attr name="ptrAnimationStyle">
            <flag name="rotate" value="0x0" />
            <flag name="flip" value="0x1" />
        </attr>
        <!-- 刷新的時候,是否容許ListView或GridView滾動 -->
        <attr name="ptrScrollingWhileRefreshingEnabled" format="reference|boolean" />
        <!-- 決定了Header,Footer以何種方式加入mPullRefreshListView,true爲headView方式加入,就是滾動時刷新頭部會一塊兒滾動,false不能刷新 -->
        <attr name="ptrListViewExtrasEnabled" format="reference|boolean" />
        <!-- 拉的時候頭部或者尾部的刷新圖片,是否屢次旋轉,true屢次,false只是旋轉一週,在下拉,圖片不會在跟着旋轉 -->
        <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>

以上就是他全部的屬性了,具體怎麼使用呢,咱們只須要咱們佈局文件的頭部加入:android

xmlns:ptr="http://schemas.android.com/apk/res-auto"

而後就能夠在pulltorefresh節點的xml文件使用它的屬性,如:佈局

 ptr:ptrMode="both"

這樣,咱們就設置了,這個pulltorefresh的模式是上拉下拉雙支持的字體

相關文章
相關標籤/搜索