Android ViewPagerIndicator詳解及實(shí)例代碼
Android ViewPagerIndicator詳解及實(shí)例代碼
關(guān)于自定義View的屬性零碎知識(shí)
自定義View和自定義屬性的知識(shí)不再此提及,這里著重說(shuō)的是屬性在自定義View中的獲取方式,自定義的屬性如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="Wisely">
<attr name="wisely_1" format="boolean" />
<attr name="wisely_2" format="boolean" />
<attr name="wisely_3" format="boolean" />
<attr name="wisely_4" format="boolean" />
</declare-styleable>
<attr name="wisely_out" format="boolean" />
</resources>
自定義View的相關(guān)代碼如下:
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Wisely);
typedArray.getBoolean(R.styleable.Wisely_wisely_1, true);
typedArray.recycle();
}
重點(diǎn)看R.styleable.Wisely,它返回的是一個(gè)數(shù)組,而R.styleable.Wisely_wisely_1表示的則是數(shù)組的索引,它們?cè)赗文件中的表示如下:
public static final class attr {
public static final int wisely_1 = 0x7f010000;
public static final int wisely_2 = 0x7f010001;
public static final int wisely_3 = 0x7f010002;
public static final int wisely_4 = 0x7f010003;
public static final int wisely_out = 0x7f010004;
}
public static final class styleable {
public static final int[] Wisely = { 0x7f010000, 0x7f010001,
0x7f010002, 0x7f010003 };
public static final int Wisely_wisely_1 = 0;
public static final int Wisely_wisely_2 = 1;
public static final int Wisely_wisely_3 = 2;
public static final int Wisely_wisely_4 = 3;
}
從上面可以看出一點(diǎn),wisely_out也是attrs.xml中的屬性,不過(guò)它是寫在以Wisely命名的標(biāo)簽之外的,所以并未列入到styleable類的Wisely數(shù)組中。
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
Android CountDownTimer案例總結(jié)
這篇文章主要介紹了Android CountDownTimer案例總結(jié),本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08
Android項(xiàng)目實(shí)現(xiàn)黑名單攔截效果
本篇文章主要介紹了Android項(xiàng)目實(shí)現(xiàn)黑名單攔截效果,可以根據(jù)白名單或者黑名單攔截,測(cè)試可以攔截電話,有需要的朋友可以了解一下。2016-10-10
關(guān)于Touch Panel AA區(qū)要做外擴(kuò)的原因解析
今天小編就為大家分享一篇關(guān)于Touch Panel AA區(qū)要做外擴(kuò)的原因解析,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2018-12-12
Android Studio設(shè)置或修改Android SDK路徑方法
在本篇文章中小編給大家整理了關(guān)于Android Studio設(shè)置或修改Android SDK路徑方法和相關(guān)知識(shí)點(diǎn),需要的朋友們學(xué)習(xí)下。2019-04-04
Android一步步帶你在RecyclerView上面實(shí)現(xiàn)"拖放"和"滑動(dòng)刪除"功能
這篇文章主要介紹了Android一步步帶你在RecyclerView上面實(shí)現(xiàn)"拖放"和"滑動(dòng)刪除"功能,需非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下2017-03-03
Android 全屏無(wú)標(biāo)題欄的三種實(shí)現(xiàn)方法
這篇文章主要介紹了Android的三種實(shí)現(xiàn)方法的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07
Android基于TextView實(shí)現(xiàn)跑馬燈效果
這篇文章主要為大家詳細(xì)介紹了Android基于TextView實(shí)現(xiàn)跑馬燈效果的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03
Android動(dòng)畫之補(bǔ)間動(dòng)畫(Tween Animation)實(shí)例詳解
這篇文章主要介紹了Android動(dòng)畫之補(bǔ)間動(dòng)畫(Tween Animation)用法,結(jié)合實(shí)例形式較為詳細(xì)的分析了Android補(bǔ)間動(dòng)畫的定義,原理,注意事項(xiàng)與相關(guān)使用技巧,需要的朋友可以參考下2016-01-01
Android中Activity過(guò)渡動(dòng)畫的實(shí)例講解
在android5.0 以上版本中,google為我們提供了幾種activity切換的過(guò)渡動(dòng)畫,目的是為了讓 activity 切換轉(zhuǎn)場(chǎng)更加美觀,下面這篇文章主要給大家介紹了關(guān)于Android中Activity過(guò)渡動(dòng)畫的相關(guān)資料,需要的朋友可以參考下2021-11-11

