第三方包属性的定义(这里是以刷新库为例)

来源:互联网 发布:好看的悬疑网络剧 编辑:程序博客网 时间:2024/04/28 06:47

下面是以pulltorefresh内部的刷新库为例:
1.在xml布局内,使用方法如下:

<com.handmark.pulltorefresh.library.PullToRefreshScrollView        xmlns:ptr="http://schemas.android.com/apk/res-auto"        android:id="@+id/meet_story_main_scroll"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:scrollbars="none"        android:layout_below="@+id/meet_title_bar"        ptr:ptrHeaderBackground="#00ff00"        ptr:ptrHeaderTextColor="@color/meet_gray_color"        ptr:ptrListViewExtrasEnabled="false"        ptr:ptrScrollingWhileRefreshingEnabled="true" />

2.它的文件在values文件夹下的atts.xml内:如下

<?xml version="1.0" encoding="utf-8"?><resources>    <declare-styleable name="PullToRefresh">        <!-- A drawable to use as the background of the Refreshable View -->        <attr name="ptrRefreshableViewBackground" format="reference|color" />        <!-- A drawable to use as the background of the Header and Footer Loading Views -->        <attr name="ptrHeaderBackground" format="reference|color" />        <!-- Text Color of the Header and Footer Loading Views -->        <attr name="ptrHeaderTextColor" format="reference|color" />        <!-- Text Color of the Header and Footer Loading Views Sub Header -->        <attr name="ptrHeaderSubTextColor" format="reference|color" />        <!-- Mode of Pull-to-Refresh that should be used -->        <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>        <!-- Whether the Indicator overlay(s) should be used -->        <attr name="ptrShowIndicator" format="reference|boolean" />        <!-- Drawable to use as Loading Indicator. Changes both Header and Footer. -->        <attr name="ptrDrawable" format="reference" />        <!-- Drawable to use as Loading Indicator in the Header View. Overrides value set in ptrDrawable. -->        <attr name="ptrDrawableStart" format="reference" />        <!-- Drawable to use as Loading Indicator in the Footer View. Overrides value set in ptrDrawable. -->        <attr name="ptrDrawableEnd" format="reference" />        <!-- Whether Android's built-in Over Scroll should 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 -->        <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 should be used displayed when pulling. -->        <attr name="ptrAnimationStyle">            <flag name="rotate" value="0x0" />            <flag name="flip" value="0x1" />        </attr>        <!-- Whether the user can scroll while the View is 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.        -->        <attr name="ptrListViewExtrasEnabled" format="reference|boolean" />        <!--            Whether the Drawable should 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>

在代码中也是可以写的,如下:

if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance)) {            TypedValue styleID = new TypedValue();            attrs.getValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance, styleID);            setTextAppearance(styleID.data);        }

现在很多都是使用这种属性,了解一下操作起来很是方便。

1 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 医保卡不能用了怎么办 招行u盾丢了怎么办 信用卡刷爆了要怎么办 办分期的卡丢了怎么办 房贷银行卡掉了怎么办 房贷银行卡丢了怎么办? 行驶证丢了怎么办补办 行驶证丢了怎么办异地 浦发信用卡盗刷怎么办 苹果id被盗变砖怎么办 信用卡丢了被刷怎么办 ins注册不了怎么办安卓 偷玩电脑被发现怎么办 做作业不认真的怎么办 老人脑供血不足怎么办 哺乳期吃了辣的怎么办 孕32周胎位臀位怎么办 怀孕32周胎位不正怎么办 7个月胎位不正怎么办 胎心监护老不过怎么办 8个月了胎位不正怎么办 怀孕八个月了胎位不正怎么办 怀孕八个月胎位不正怎么办 欠债的人跑了怎么办 赌博输了100万怎么办 我赌博输了4万怎么办 办80张信用卡怎么办的 19岁负债十几万怎么办 欠了十几万该怎么办 网贷负债十几万怎么办 赌博欠了十几万怎么办 欠了网贷跑了会怎么办 欠银行钱还不起怎么办 欠小额贷款公司的钱还不上怎么办 负债30万没工作怎么办 华为p9耗电太快怎么办 酷派手机反应慢怎么办 网上买手机被骗了怎么办 买手机贵了怎么办12315 在手机店被骗了怎么办 在转转上被骗了怎么办