当前位置: 首页>>代码示例>>Java>>正文


Java TypedArray.getColor方法代码示例

本文整理汇总了Java中android.content.res.TypedArray.getColor方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getColor方法的具体用法?Java TypedArray.getColor怎么用?Java TypedArray.getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.res.TypedArray的用法示例。


在下文中一共展示了TypedArray.getColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: IconCache

import android.content.res.TypedArray; //导入方法依赖的package包/类
public IconCache(Context context, InvariantDeviceProfile inv) {
    mContext = context;
    mPackageManager = context.getPackageManager();
    mUserManager = UserManagerCompat.getInstance(mContext);
    mLauncherApps = LauncherAppsCompat.getInstance(mContext);
    mIconDpi = inv.fillResIconDpi;
    mIconDb = new IconDB(context, inv.iconBitmapSize);
    mLowResCanvas = new Canvas();
    mLowResPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);

    mIconProvider = IconProvider.loadByName(context.getString(R.string.icon_provider_class),
            context);

    mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());

    mActivityBgColor = context.getResources().getColor(R.color.quantum_panel_bg_color);
    TypedArray ta = context.obtainStyledAttributes(new int[]{R.attr.colorSecondary});
    mPackageBgColor = ta.getColor(0, 0);
    ta.recycle();
    mLowResOptions = new BitmapFactory.Options();
    // Always prefer RGB_565 config for low res. If the bitmap has transparency, it will
    // automatically be loaded as ALPHA_8888.
    mLowResOptions.inPreferredConfig = Bitmap.Config.RGB_565;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:25,代码来源:IconCache.java

示例2: initAttrs

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttrs(AttributeSet paramAttributeSet) {
    if (paramAttributeSet != null) {
        TypedArray typedArray = getContext().obtainStyledAttributes(paramAttributeSet, R.styleable.TimeLineView);
        mStartedLineColor = typedArray.getColor(R.styleable.TimeLineView_startedLineColor, Color.BLUE);
        mPreLineColor = typedArray.getColor(R.styleable.TimeLineView_preLineColor, Color.GRAY);

        mStartedCircleColor = typedArray.getColor(R.styleable.TimeLineView_startedCircleColor, Color.BLUE);
        mUnderwayCircleColor = typedArray.getColor(R.styleable.TimeLineView_underwayCircleColor, Color.BLUE);
        mPreCircleColor = typedArray.getColor(R.styleable.TimeLineView_preCircleColor, Color.GRAY);

        mStartedStringColor = typedArray.getColor(R.styleable.TimeLineView_startedStringColor, Color.BLUE);
        mUnderwayStringColor = typedArray.getColor(R.styleable.TimeLineView_underwayStringColor, Color.BLUE);
        mPreStringColor = typedArray.getColor(R.styleable.TimeLineView_preStringColor, Color.GRAY);
        mTextSize = typedArray.getDimension(R.styleable.TimeLineView_textSize, 20);
        mRadius = (int) typedArray.getDimension(R.styleable.TimeLineView_radius, 10);
        mLineWidth = typedArray.getDimension(R.styleable.TimeLineView_lineWidth, 5);
        typedArray.recycle();
    }
}
 
开发者ID:WrBug,项目名称:timelineview,代码行数:20,代码来源:TimeLineView.java

示例3: CircleImageView

import android.content.res.TypedArray; //导入方法依赖的package包/类
public CircleImageView(Context c, AttributeSet attrs, int defStyleAttr) {
    super(c, attrs, defStyleAttr);
    DisplayMetrics dm = getResources().getDisplayMetrics();

    // Set XML attributes
    TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.CircleImageView);
    this.borderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_borderWidth, (int)(1f * dm.density)); // 1dp
    this.borderColor = a.getColor(R.styleable.CircleImageView_borderColor, ContextCompat.getColor(c, R.color.default_circle_border_color));
    this.backColor = a.getColor(R.styleable.CircleImageView_circleColor, ContextCompat.getColor(c, R.color.default_circle_text_color));
    a.recycle();

    // Setup border paint
    this.borderPaint.setStyle(Paint.Style.FILL);
    this.borderPaint.setColor(borderColor);

    // Setup main paint
    this.mainPaint.setColor(ContextCompat.getColor(c, R.color.default_circle_text_color));
    this.mainPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
}
 
开发者ID:tylersuehr7,项目名称:bubble-layout,代码行数:20,代码来源:CircleImageView.java

示例4: init

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    mMinWidth = 24;
    mMaxWidth = 48;
    mMinHeight = 24;
    mMaxHeight = 48;

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

    mMinWidth = a.getDimensionPixelSize(R.styleable.LoadingIndicatorView_minWidth, mMinWidth);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.LoadingIndicatorView_maxWidth, mMaxWidth);
    mMinHeight = a.getDimensionPixelSize(R.styleable.LoadingIndicatorView_minHeight, mMinHeight);
    mMaxHeight = a.getDimensionPixelSize(R.styleable.LoadingIndicatorView_maxHeight, mMaxHeight);
    String indicatorName = a.getString(R.styleable.LoadingIndicatorView_indicatorName);
    mIndicatorColor = a.getColor(R.styleable.LoadingIndicatorView_indicatorColor, Color.WHITE);
    setIndicator(indicatorName);
    if (mIndicator == null) {
        setIndicator(DEFAULT_INDICATOR);
    }
    a.recycle();
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:22,代码来源:LoadingIndicatorView.java

示例5: initAttr

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttr(AttributeSet attrs) {
    TypedArray t = getContext().obtainStyledAttributes(attrs,R.styleable.WaveLineView);
    backGroundColor = t.getColor(R.styleable.WaveLineView_wlvBackgroundColor, Color.WHITE);
    samplingSize = t.getInt(R.styleable.WaveLineView_wlvSamplingSize, DEFAULT_SAMPLING_SIZE);
    lineColor = t.getColor(R.styleable.WaveLineView_wlvLineColor, Color.parseColor("#2ED184"));
    thickLineWidth = (int)t.getDimension(R.styleable.WaveLineView_wlvThickLineWidth, 6);
    fineLineWidth = (int)t.getDimension(R.styleable.WaveLineView_wlvFineLineWidth, 2);
    offsetSpeed = t.getFloat(R.styleable.WaveLineView_wlvMoveSpeed, DEFAULT_OFFSET_SPEED);
    sensibility = t.getInt(R.styleable.WaveLineView_wlvSensibility, DEFAULT_SENSIBILITY);
    isTransparentMode = backGroundColor == Color.TRANSPARENT;
    t.recycle();
    checkVolumeValue();
    checkSensibilityValue();
    //将RenderView放到最顶层
    setZOrderOnTop(true);
    if (getHolder() != null) {
        //使窗口支持透明度
        getHolder().setFormat(PixelFormat.TRANSLUCENT);
    }
}
 
开发者ID:Jay-Goo,项目名称:WaveLineView,代码行数:21,代码来源:WaveLineView.java

示例6: init

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    //初始化默认值
    mPressAlpha = 64;
    mPressColor = getResources().getColor(R.color.ml_gray);
    mRadius = 16;
    mShapeType = 1;
    mBorderWidth = 0;
    mBorderColor = getResources().getColor(R.color.ml_red);

    // 获取控件的属性值
    if (attrs != null) {
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.MLImageView);
        mPressColor = array.getColor(R.styleable.MLImageView_press_color, mPressColor);
        mPressAlpha = array.getInteger(R.styleable.MLImageView_press_alpha, mPressAlpha);
        mRadius = array.getDimensionPixelSize(R.styleable.MLImageView_radius, mRadius);
        mShapeType = array.getInteger(R.styleable.MLImageView_shape_type, mShapeType);
        mBorderWidth = array.getDimensionPixelOffset(R.styleable.MLImageView_border_width, mBorderWidth);
        mBorderColor = array.getColor(R.styleable.MLImageView_border_color, mBorderColor);
        array.recycle();
    }

    // 按下的画笔设置
    mPressPaint = new Paint();
    mPressPaint.setAntiAlias(true);
    mPressPaint.setStyle(Paint.Style.FILL);
    mPressPaint.setColor(mPressColor);
    mPressPaint.setAlpha(0);
    mPressPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    setClickable(true);
    setDrawingCacheEnabled(true);
    setWillNotDraw(false);
}
 
开发者ID:dufangyu1990,项目名称:JKApp,代码行数:34,代码来源:MLImageView.java

示例7: StationIndicator

import android.content.res.TypedArray; //导入方法依赖的package包/类
public StationIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    paint = new Paint();
    TypedArray mTypedArray = context.obtainStyledAttributes(attrs, R.styleable.IndicatorItem);
    color = mTypedArray.getColor(R.styleable.IndicatorItem_indicatorColor, ThemeUtil.getThemeColor(context, R.attr.colorPrimary));
    roundWidth = mTypedArray.getDimension(R.styleable.IndicatorItem_indicatorRingWidth, SizeUtils.dp2px(context, 3));
    isChecked = mTypedArray.getBoolean(R.styleable.IndicatorItem_indicatorChecked, false);
    innerCircle = mTypedArray.getDimension(R.styleable.IndicatorItem_indicatorInnerCircle, SizeUtils.dp2px(context, 4));
    mTypedArray.recycle();

}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:13,代码来源:StationIndicator.java

示例8: init

import android.content.res.TypedArray; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void init(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray tp = getContext().obtainStyledAttributes(attrs, R.styleable.CodeWebView);
        try {
            backgroundColor = tp.getColor(R.styleable.CodeWebView_webview_background,
                    ViewUtils.getWindowBackground(getContext()));
            setBackgroundColor(backgroundColor);
        } finally {
            tp.recycle();
        }
    }

    setWebChromeClient(new ChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        setWebViewClient(new WebClientN());
    } else {
        setWebViewClient(new WebClient());
    }
    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAppCachePath(getContext().getCacheDir().getPath());
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setDefaultTextEncodingName("utf-8");
    settings.setLoadsImagesAutomatically(true);
    settings.setBlockNetworkImage(false);
    setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            WebView.HitTestResult result = getHitTestResult();
            if (hitLinkResult(result) && !StringUtils.isBlank(result.getExtra())) {
                AppUtils.copyToClipboard(getContext(), result.getExtra());
                return true;
            }
            return false;
        }
    });
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:40,代码来源:CodeWebView.java

示例9: init

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TriangleView);
        switch (a.getInt(R.styleable.TriangleView_tr_direction, 0)) {
            case 0:
                mDirection = Direction.LEFT;
                break;
            case 1:
                mDirection = Direction.UP;
                break;
            case 2:
                mDirection = Direction.RIGHT;
                break;
            case 3:
            default:
                mDirection = Direction.DOWN;
        }
        mColor = a.getColor(R.styleable.TriangleView_tr_color, DEFAULT_COLOR);
        a.recycle();
    } else {
        mDirection = DEFAULT_DIRECTION;
        mColor = DEFAULT_COLOR;
    }

    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(mColor);
    mPaint.setAntiAlias(true);

    LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    int margin = (int) getResources().getDimension(R.dimen._minus5sdp);

    // setPadding(margin, margin, margin, margin);
    llParams.setMargins(margin, margin, margin, margin);
    setLayoutParams(llParams);
}
 
开发者ID:milaptank,项目名称:BiColorView,代码行数:38,代码来源:TriangleView.java

示例10: NumberProgressBar

import android.content.res.TypedArray; //导入方法依赖的package包/类
public NumberProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mContext = context;

    default_reached_bar_height = dp2px(10.5f);
    default_unreached_bar_height = dp2px(10.0f);
    default_text_size = sp2px(10);
    default_progress_text_offset = dp2px(3.0f);

    //load styled attributes.
    final TypedArray attributes = context.getTheme().obtainStyledAttributes(attrs, R.styleable.NumberProgressBar,
            defStyleAttr, 0);

    mReachedBarColor = attributes.getColor(R.styleable.NumberProgressBar_progress_reached_color, default_reached_color);
    mUnreachedBarColor = attributes.getColor(R.styleable.NumberProgressBar_progress_unreached_color,default_unreached_color);
    mTextColor = attributes.getColor(R.styleable.NumberProgressBar_progress_text_color,default_text_color);
    mTextSize = attributes.getDimension(R.styleable.NumberProgressBar_progress_text_size, default_text_size);

    mReachedBarHeight = attributes.getDimension(R.styleable.NumberProgressBar_progress_reached_bar_height,default_reached_bar_height);
    mUnreachedBarHeight = attributes.getDimension(R.styleable.NumberProgressBar_progress_unreached_bar_height,default_unreached_bar_height);
    mOffset = attributes.getDimension(R.styleable.NumberProgressBar_progress_text_offset,default_progress_text_offset);

    int textVisible = attributes.getInt(R.styleable.NumberProgressBar_progress_text_visibility,PROGRESS_TEXT_VISIBLE);
    if(textVisible != PROGRESS_TEXT_VISIBLE){
        mIfDrawText = false;
    }

    setProgress(attributes.getInt(R.styleable.NumberProgressBar_progress,0));
    setMax(attributes.getInt(R.styleable.NumberProgressBar_max, 100));
    //
    attributes.recycle();

    initializePainters();

}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:37,代码来源:NumberProgressBar.java

示例11: init

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attributeSet) {
    mAddButtonPlusColor = getColor(android.R.color.white);
    mAddButtonColorNormal = getColor(android.R.color.holo_blue_dark);
    mAddButtonColorPressed = getColor(android.R.color.holo_blue_light);

    mButtonSpacing = (int) (getResources().getDimension(R.dimen.fab_actions_spacing) - getResources().getDimension(R.dimen.fab_shadow_radius) - getResources().getDimension(R.dimen.fab_shadow_offset));

    if (attributeSet != null) {
        TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.FloatingActionsMenu, 0, 0);
        if (attr != null) {
            try {
                mAddButtonPlusColor = attr.getColor(R.styleable.FloatingActionsMenu_addButtonPlusIconColor, getColor(android.R.color.white));
                mAddButtonColorNormal = attr.getColor(R.styleable.FloatingActionsMenu_addButtonColorNormal, getColor(android.R.color.holo_blue_dark));
                mAddButtonColorPressed = attr.getColor(R.styleable.FloatingActionsMenu_addButtonColorPressed, getColor(android.R.color.holo_blue_light));
                isHorizontal = attr.getBoolean(R.styleable.FloatingActionsMenu_addButtonIsHorizontal, false);
            } finally {
                attr.recycle();
            }
        }
    }
    WindowManager mWindowManager = (WindowManager)
            context.getSystemService(Context.WINDOW_SERVICE);
    Display display = mWindowManager.getDefaultDisplay();
    Point size = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(size);
        mYHidden = size.y;
    } else mYHidden = display.getHeight();

    createAddButton(context);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:FloatingActionsMenu.java

示例12: obtainData

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void obtainData(AttributeSet attrs) {
    TypedArray a=getContext().obtainStyledAttributes(attrs, R.styleable.SLoading);
    radius=a.getDimension(R.styleable.SLoading_sradius,-1);
    gap=a.getDimension(R.styleable.SLoading_sgap,-1);
    num=a.getInt(R.styleable.SLoading_snum,-1);
    color=a.getColor(R.styleable.SLoading_scolor,0xff4070);
    a.recycle();
}
 
开发者ID:While1true,项目名称:JSSample,代码行数:9,代码来源:SLoading.java

示例13: getValueOfColorAttr

import android.content.res.TypedArray; //导入方法依赖的package包/类
public static int[] getValueOfColorAttr(Context context, int defaultColor, int... attrs) {
    if (attrs.length == 0) {
        return attrs;
    }
    int[] colors = new int[attrs.length];
    TypedArray array = context.obtainStyledAttributes(attrs);
    for (int i = 0; i < attrs.length; i++) {
        colors[i] = array.getColor(i, defaultColor);
    }
    array.recycle();
    return colors;
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:13,代码来源:ResourcesUtils.java

示例14: WaveView

import android.content.res.TypedArray; //导入方法依赖的package包/类
public WaveView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setOrientation(VERTICAL);
    //load styled attributes.
    final TypedArray attributes = context.getTheme().obtainStyledAttributes(attrs, R.styleable.WaveView, R.attr.waveViewStyle, 0);
    mAboveWaveColor = attributes.getColor(R.styleable.WaveView_above_wave_color, DEFAULT_ABOVE_WAVE_COLOR);
    mBlowWaveColor = attributes.getColor(R.styleable.WaveView_blow_wave_color, DEFAULT_BLOW_WAVE_COLOR);
    mProgress = attributes.getInt(R.styleable.WaveView_progress, DEFAULT_PROGRESS);
    mWaveHeight = attributes.getInt(R.styleable.WaveView_wave_height, MIDDLE);
    mWaveMultiple = attributes.getInt(R.styleable.WaveView_wave_length, LARGE);
    mWaveHz = attributes.getInt(R.styleable.WaveView_wave_hz, MIDDLE);
    attributes.recycle();

    mWave = new Wave(context, null);
    mWave.initializeWaveSize(mWaveMultiple, mWaveHeight, mWaveHz);
    mWave.setAboveWaveColor(mAboveWaveColor);
    mWave.setBlowWaveColor(mBlowWaveColor);
    mWave.initializePainters();

    mSolid = new Solid(context, null);
    mSolid.setAboveWavePaint(mWave.getAboveWavePaint());
    mSolid.setBlowWavePaint(mWave.getBlowWavePaint());

    addView(mWave);
    addView(mSolid);

    setProgress(mProgress);
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:29,代码来源:WaveView.java

示例15: initAttrs

import android.content.res.TypedArray; //导入方法依赖的package包/类
protected void initAttrs(AttributeSet attrs) {
    TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.PraiseListView, 0, 0);
    try {
        //textview的默认颜色
        itemColor = typedArray.getColor(R.styleable.PraiseListView_item_color, getResources().getColor(R.color.praise_item_default));
        itemSelectorColor = typedArray.getColor(R.styleable.PraiseListView_item_selector_color, getResources().getColor(R.color.praise_item_selector_default));

    }finally {
        typedArray.recycle();
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:12,代码来源:CommentListView.java


注:本文中的android.content.res.TypedArray.getColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。