當前位置: 首頁>>代碼示例>>Java>>正文


Java Resources.getColor方法代碼示例

本文整理匯總了Java中android.content.res.Resources.getColor方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getColor方法的具體用法?Java Resources.getColor怎麽用?Java Resources.getColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.getColor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRowBackgroundColor

import android.content.res.Resources; //導入方法依賴的package包/類
public static int getRowBackgroundColor(ATableView tableView, ATableViewCell cell) {
    Resources res = tableView.getResources();

    // -1 implies no color defined.
    int color = cell.getBackgroundColor();
    if (color == -1) {
        int tableBackgroundColor = tableView.getBackgroundColor();
        if (tableBackgroundColor == -1) {
            color = res.getColor(R.color.atv_plain_background);
            if (tableView.getStyle() == ATableViewStyle.Grouped) {
                color = res.getColor(R.color.atv_cell_grouped_background);
            }
        } else {
            color = tableBackgroundColor;
        }
    }

    return color;
}
 
開發者ID:hh-in-zhuzhou,項目名稱:ShangHanLun,代碼行數:20,代碼來源:DrawableUtils.java

示例2: SimpleMonthView

import android.content.res.Resources; //導入方法依賴的package包/類
public SimpleMonthView(Context context) {
	super(context);
	Resources resources = context.getResources();
	mDayLabelCalendar = Calendar.getInstance();
	mCalendar = Calendar.getInstance();

	mDayOfWeekTypeface = resources.getString(R.string.day_of_week_label_typeface);
	mMonthTitleTypeface = resources.getString(R.string.sans_serif);
	mDayTextColor = resources.getColor(R.color.date_picker_text_normal);
	mTodayNumberColor = resources.getColor(R.color.blue);
	mMonthTitleColor = resources.getColor(R.color.white);
	mMonthTitleBGColor = resources.getColor(R.color.circle_background);

	mStringBuilder = new StringBuilder(50);
	mFormatter = new Formatter(mStringBuilder, Locale.getDefault());

	MINI_DAY_NUMBER_TEXT_SIZE = resources.getDimensionPixelSize(R.dimen.day_number_size);
	MONTH_LABEL_TEXT_SIZE = resources.getDimensionPixelSize(R.dimen.month_label_size);
	MONTH_DAY_LABEL_TEXT_SIZE = resources.getDimensionPixelSize(R.dimen.month_day_label_text_size);
	MONTH_HEADER_SIZE = resources.getDimensionPixelOffset(R.dimen.month_list_item_header_height);
	DAY_SELECTED_CIRCLE_SIZE = resources.getDimensionPixelSize(R.dimen.day_number_select_circle_radius);

	mRowHeight = ((resources.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / 6);

       initView();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:SimpleMonthView.java

示例3: ViewfinderView

import android.content.res.Resources; //導入方法依賴的package包/類
public ViewfinderView(Context context, AttributeSet attrs) {
	super(context, attrs);
	// Initialize these once for performance rather than calling them every
	// time in onDraw().
	density = context.getResources().getDisplayMetrics().density;
	// 將像素轉換成dp
	ScreenRate = (int) (20 * density);
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	Resources resources = getResources();
	maskColor = resources.getColor(R.color.viewfinder_mask);
	resultColor = resources.getColor(R.color.result_view);

	resultPointColor = resources.getColor(R.color.possible_result_points);
	possibleResultPoints = new ArrayList<ResultPoint>(5);
	lastPossibleResultPoints = null;
}
 
開發者ID:dufangyu1990,項目名稱:LeCatApp,代碼行數:17,代碼來源:ViewfinderView.java

示例4: getPurpleColor

import android.content.res.Resources; //導入方法依賴的package包/類
public static int[] getPurpleColor(Context context) {
    int[] color = new int[14];
    Resources resources = context.getResources();
    if (resources != null) {
        for (int i = 1; i <= 14; i++) {
            color[i - 1] = resources.getColor(ResUtils.getColorId(context, "smart_color_purple" + i));
        }
    }
    return color;
}
 
開發者ID:miaolingzi,項目名稱:SmartColorView,代碼行數:11,代碼來源:ColorUtils.java

示例5: LinePageIndicator

import android.content.res.Resources; //導入方法依賴的package包/類
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected.setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();
}
 
開發者ID:hanhailong,項目名稱:GridPagerSnapHelper,代碼行數:32,代碼來源:LinePageIndicator.java

示例6: UnderlinePageIndicator

import android.content.res.Resources; //導入方法依賴的package包/類
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    final Resources res = getResources();

    //Load defaults from resources
    final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length);
    final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0);

    setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades));
    setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));

    Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background);
    if (background != null) {
      setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:31,代碼來源:UnderlinePageIndicator.java

示例7: ViewfinderView

import android.content.res.Resources; //導入方法依賴的package包/類
public ViewfinderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Initialize these once for performance rather than calling them every time in onDraw().
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    Resources resources = getResources();
    maskColor = resources.getColor(R.color.viewfinder_mask);
    resultColor = resources.getColor(R.color.result_view);
    laserColor = resources.getColor(R.color.viewfinder_laser);
    resultPointColor = resources.getColor(R.color.possible_result_points);
    scannerAlpha = 0;
    possibleResultPoints = new ArrayList<>(5);
    lastPossibleResultPoints = null;
}
 
開發者ID:xiong-it,項目名稱:ZXingAndroidExt,代碼行數:15,代碼來源:ViewfinderView.java

示例8: setProgressColorSchemeColorsFromResource

import android.content.res.Resources; //導入方法依賴的package包/類
public void setProgressColorSchemeColorsFromResource(@IdRes int... resources) {
    final Resources res = getResources();
    final int[] colorRes = new int[resources.length];

    for (int i = 0; i < resources.length; i++) {
        colorRes[i] = res.getColor(resources[i]);
    }

    setColorSchemeColors(colorRes);
}
 
開發者ID:scwang90,項目名稱:SmartRefreshLayout,代碼行數:11,代碼來源:WaveSwipeHeader.java

示例9: LinePageIndicator

import android.content.res.Resources; //導入方法依賴的package包/類
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected.setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
      setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:35,代碼來源:LinePageIndicator.java

示例10: ViewfinderView

import android.content.res.Resources; //導入方法依賴的package包/類
public ViewfinderView(Context context, AttributeSet attrs) {
  super(context, attrs);

  // Initialize these once for performance rather than calling them every time in onDraw().
  paint = new Paint();
  Resources resources = getResources();
  maskColor = resources.getColor(R.color.viewfinder_mask);
  resultColor = resources.getColor(R.color.result_view);
  frameColor = resources.getColor(R.color.viewfinder_frame);
  laserColor = resources.getColor(R.color.viewfinder_laser);
  resultPointColor = resources.getColor(R.color.possible_result_points);
  scannerAlpha = 0;
  possibleResultPoints = new HashSet<ResultPoint>(5);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:ViewfinderView.java

示例11: getColor

import android.content.res.Resources; //導入方法依賴的package包/類
public int getColor(Context context, int colorRes) {
    Resources resources = context.getResources();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        return resources.getColor(colorRes, null);
    }
    return resources.getColor(colorRes);
}
 
開發者ID:sinhaDroid,項目名稱:BlogBookApp,代碼行數:8,代碼來源:InAppActivity.java

示例12: initialize

import android.content.res.Resources; //導入方法依賴的package包/類
public void initialize(Context context, TimePickerController controller, int amOrPm) {
    if (this.mIsInitialized) {
        Log.e(TAG, "AmPmCirclesView may only be initialized once.");
        return;
    }
    Resources res = context.getResources();
    if (controller.isThemeDark()) {
        this.mUnselectedColor = res.getColor(R.color.mdtp_circle_background_dark_theme);
        this.mAmPmTextColor = res.getColor(R.color.mdtp_white);
        this.mSelectedAlpha = 255;
    } else {
        this.mUnselectedColor = res.getColor(R.color.mdtp_white);
        this.mAmPmTextColor = res.getColor(R.color.mdtp_ampm_text_color);
        this.mSelectedAlpha = 255;
    }
    this.mSelectedColor = controller.getAccentColor();
    this.mTouchedColor = Utils.darkenColor(this.mSelectedColor);
    this.mAmPmSelectedTextColor = res.getColor(R.color.mdtp_white);
    this.mPaint.setTypeface(Typeface.create(res.getString(R.string.mdtp_sans_serif), 0));
    this.mPaint.setAntiAlias(true);
    this.mPaint.setTextAlign(Align.CENTER);
    this.mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string
            .mdtp_circle_radius_multiplier));
    this.mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string
            .mdtp_ampm_circle_radius_multiplier));
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    this.mAmText = amPmTexts[0];
    this.mPmText = amPmTexts[1];
    setAmOrPm(amOrPm);
    this.mAmOrPmPressed = -1;
    this.mIsInitialized = true;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:33,代碼來源:AmPmCirclesView.java

示例13: setColorSchemeResources

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Set the color resources used in the progress animation from color resources.
 * The first color will also be the color of the bar that grows in response
 * to a user swipe gesture.
 *
 * @param colorResIds
 */
public void setColorSchemeResources(int... colorResIds) {
    final Resources res = getResources();
    int[] colorRes = new int[colorResIds.length];
    for (int i = 0; i < colorResIds.length; i++) {
        colorRes[i] = res.getColor(colorResIds[i]);
    }
    setColorSchemeColors(colorRes);
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:16,代碼來源:LingjuSwipeRefreshLayout.java

示例14: Utils

import android.content.res.Resources; //導入方法依賴的package包/類
public Utils(Context context) {
	Resources r = context.getResources();
	this.positiveColor = r.getColor(R.color.positive_amount);
	this.negativeColor = r.getColor(R.color.negative_amount);
       this.transferColor = r.getColor(R.color.transfer_color);
       this.futureColor = r.getColor(R.color.future_color);
       this.context = context;
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:9,代碼來源:Utils.java

示例15: LinePageIndicator

import android.content.res.Resources; //導入方法依賴的package包/類
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.mPaintUnselected = new Paint(1);
    this.mPaintSelected = new Paint(1);
    this.mLastMotionX = -1.0f;
    this.mActivePointerId = -1;
    if (!isInEditMode()) {
        Resources res = getResources();
        int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
        int defaultUnselectedColor = res.getColor(R.color
                .default_line_indicator_unselected_color);
        float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
        float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
        float defaultStrokeWidth = res.getDimension(R.dimen
                .default_line_indicator_stroke_width);
        boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator,
                defStyle, 0);
        this.mCentered = a.getBoolean(1, defaultCentered);
        this.mLineWidth = a.getDimension(5, defaultLineWidth);
        this.mGapWidth = a.getDimension(6, defaultGapWidth);
        setStrokeWidth(a.getDimension(3, defaultStrokeWidth));
        this.mPaintUnselected.setColor(a.getColor(4, defaultUnselectedColor));
        this.mPaintSelected.setColor(a.getColor(2, defaultSelectedColor));
        Drawable background = a.getDrawable(0);
        if (background != null) {
            setBackgroundDrawable(background);
        }
        a.recycle();
        this.mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfiguration
                .get(context));
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:34,代碼來源:LinePageIndicator.java


注:本文中的android.content.res.Resources.getColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。