WindySha / XSkinLoader

侵入性最低,功能强大的Android换肤框架XSkinLoader
Other
173 stars 39 forks source link

关于方法参数的请教 #6

Closed JSnail closed 5 years ago

JSnail commented 5 years ago

private static int getProgressBarIndeterminateDrawableIndex() { if ( sProgressBarIndeterminateDrawableIndex == 0 ) { Object o = ReflectUtils.getField( "com.android.internal.R$styleable", "ProgressBar_indeterminateDrawable" ); if ( o != null ) { sProgressBarIndeterminateDrawableIndex = (int) o; } } return sProgressBarIndeterminateDrawableIndex; }

private static int[] getProgressBarStyleable() {
    if ( sProgressBarStyleList == null || sProgressBarStyleList.length == 0 ) {
        sProgressBarStyleList = (int[]) ReflectUtils.getField( "com.android.internal.R$styleable", "ProgressBar" );
    }
    return sProgressBarStyleList;
}

以上两个方法里面的"ProgressBar_indeterminateDrawable" 和"ProgressBar"是从什么地方得到的呢,我想增加style中其他属性的解析方法,但是不知道这个字段应该是什么

WindySha commented 5 years ago

ProcessBar.java的构造方法中有这样一段代码:


final TypedArray a = context.obtainStyledAttributes(
                attrs, R.styleable.ProgressBar, defStyleAttr, defStyleRes);

..
...

final Drawable indeterminateDrawable = a.getDrawable(
                R.styleable.ProgressBar_indeterminateDrawable);
        if (indeterminateDrawable != null) {
            if (needsTileify(indeterminateDrawable)) {
                setIndeterminateDrawableTiled(indeterminateDrawable);
            } else {
                setIndeterminateDrawable(indeterminateDrawable);
            }
        }

ProcessBar.java代码注释中也有提供这些属性声明:

 * @attr ref android.R.styleable#ProgressBar_animationResolution
 * @attr ref android.R.styleable#ProgressBar_indeterminate
 * @attr ref android.R.styleable#ProgressBar_indeterminateBehavior
 * @attr ref android.R.styleable#ProgressBar_indeterminateDrawable
 * @attr ref android.R.styleable#ProgressBar_indeterminateDuration
 * @attr ref android.R.styleable#ProgressBar_indeterminateOnly
 * @attr ref android.R.styleable#ProgressBar_interpolator
 * @attr ref android.R.styleable#ProgressBar_min
 * @attr ref android.R.styleable#ProgressBar_max
 * @attr ref android.R.styleable#ProgressBar_maxHeight
 * @attr ref android.R.styleable#ProgressBar_maxWidth
 * @attr ref android.R.styleable#ProgressBar_minHeight
 * @attr ref android.R.styleable#ProgressBar_minWidth
 * @attr ref android.R.styleable#ProgressBar_mirrorForRtl
 * @attr ref android.R.styleable#ProgressBar_progress
 * @attr ref android.R.styleable#ProgressBar_progressDrawable
 * @attr ref android.R.styleable#ProgressBar_secondaryProgress

Hope this help you.

JSnail commented 5 years ago

非常感谢