2017-06-13 76 views
0

調用obtainStyledAttributes()正確的方法是什麼什麼是Android中自定義視圖

TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomView, 0, 0); 

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomView, defStyleAttr, 0); 

回答

1

「defStyleAttr」之間的區別是 在當前主題包含的屬性引用爲TypedArray提供默認值的樣式資源。可以爲0以不尋找默認值。