本文整理匯總了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;
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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));
}
}