一:在values里新建一個(gè)resource file:

二:在自定義view中通過(guò) context.obtainStyledAttributes(attrs, R.styleable.attrSample) 方法獲取。
TypedArray ta=context.obtainStyledAttributes(attrs, R.styleable.attrSample) ;
三:在xml布局中使用該View,因?yàn)槭褂玫阶远x的參數(shù),因此會(huì)在布局根目錄進(jìn)行引用:
xmlns:app