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


Java ColorInt類代碼示例

本文整理匯總了Java中android.support.annotation.ColorInt的典型用法代碼示例。如果您正苦於以下問題:Java ColorInt類的具體用法?Java ColorInt怎麽用?Java ColorInt使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: styleAccuracy

import android.support.annotation.ColorInt; //導入依賴的package包/類
private void styleAccuracy(float accuracyAlpha, @ColorInt int accuracyColor) {
  layerMap.get(ACCURACY_LAYER).setProperties(
    circleColor(accuracyColor),
    circleOpacity(accuracyAlpha),
    circlePitchAlignment(Property.CIRCLE_PITCH_ALIGNMENT_MAP),
    circleStrokeWidth(0.5f),
    circleStrokeColor(accuracyColor)
  );
}
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:10,代碼來源:LocationLayer.java

示例2: setColor

import android.support.annotation.ColorInt; //導入依賴的package包/類
/**
 * 設置狀態欄顏色
 *
 * @param activity       需要設置的activity
 * @param color          狀態欄顏色值
 * @param statusBarAlpha 狀態欄透明度
 */
public static void setColor(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha));
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
        View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
        if (fakeStatusBarView != null) {
            if (fakeStatusBarView.getVisibility() == View.GONE) {
                fakeStatusBarView.setVisibility(View.VISIBLE);
            }
            fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        } else {
            decorView.addView(createStatusBarView(activity, color, statusBarAlpha));
        }
        setRootView(activity);
    }
}
 
開發者ID:hushengjun,項目名稱:FastAndroid,代碼行數:28,代碼來源:UIStatusBarController.java

示例3: createItemSeparatorBg

import android.support.annotation.ColorInt; //導入依賴的package包/類
/**
 * 動態創建帶上分隔線或下分隔線的Drawable
 *
 * @param separatorColor
 * @param bgColor
 * @param top
 * @return
 */
public static LayerDrawable createItemSeparatorBg(@ColorInt int separatorColor, @ColorInt int bgColor, int separatorHeight, boolean top) {

    ShapeDrawable separator = new ShapeDrawable();
    separator.getPaint().setStyle(Paint.Style.FILL);
    separator.getPaint().setColor(separatorColor);

    ShapeDrawable bg = new ShapeDrawable();
    bg.getPaint().setStyle(Paint.Style.FILL);
    bg.getPaint().setColor(bgColor);

    Drawable[] layers = {separator, bg};
    LayerDrawable layerDrawable = new LayerDrawable(layers);

    layerDrawable.setLayerInset(1, 0, top ? separatorHeight : 0, 0, top ? 0 : separatorHeight);
    return layerDrawable;
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:25,代碼來源:QMUIDrawableHelper.java

示例4: showSnackbar

import android.support.annotation.ColorInt; //導入依賴的package包/類
/**
 * 設置snackbar文字和背景顏色
 *
 * @param parent          父視圖(CoordinatorLayout或者DecorView)
 * @param text            文本
 * @param duration        顯示時長
 * @param textColor       文本顏色
 * @param bgColor         背景色
 * @param actionText      事件文本
 * @param actionTextColor 事件文本顏色
 * @param listener        監聽器
 */
private static void showSnackbar(View parent, CharSequence text, int duration, @ColorInt int textColor, @ColorInt int bgColor,
                                 CharSequence actionText, int actionTextColor, View.OnClickListener listener) {
    switch (duration) {
        default:
        case Snackbar.LENGTH_SHORT:
        case Snackbar.LENGTH_LONG:
            snackbarWeakReference = new WeakReference<>(Snackbar.make(parent, text, duration));
            break;
        case Snackbar.LENGTH_INDEFINITE:
            snackbarWeakReference = new WeakReference<>(Snackbar.make(parent, text, Snackbar.LENGTH_INDEFINITE).setDuration(duration));
    }
    View view = snackbarWeakReference.get().getView();
    ((TextView) view.findViewById(R.id.snackbar_text)).setTextColor(textColor);
    view.setBackgroundColor(bgColor);
    if (actionText != null && actionText.length() > 0 && listener != null) {
        snackbarWeakReference.get().setActionTextColor(actionTextColor);
        snackbarWeakReference.get().setAction(actionText, listener);
    }
    snackbarWeakReference.get().show();
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:33,代碼來源:SnackbarUtils.java

示例5: setColor

import android.support.annotation.ColorInt; //導入依賴的package包/類
/**
 * 設置狀態欄顏色
 *
 * @param activity       需要設置的activity
 * @param color          狀態欄顏色值
 * @param statusBarAlpha 狀態欄透明度
 */

public static void setColor(Activity activity, @ColorInt int color, int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha));
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
        int count = decorView.getChildCount();
        if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
            decorView.getChildAt(count - 1).setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        } else {
            StatusBarView statusView = createStatusBarView(activity, color, statusBarAlpha);
            decorView.addView(statusView);
        }
        setRootView(activity);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:StatusBarUtil.java

示例6: getColorShades

import android.support.annotation.ColorInt; //導入依賴的package包/類
private int[] getColorShades(@ColorInt int color) {
  return new int[]{
      shadeColor(color, 0.9),
      shadeColor(color, 0.7),
      shadeColor(color, 0.5),
      shadeColor(color, 0.333),
      shadeColor(color, 0.166),
      shadeColor(color, -0.125),
      shadeColor(color, -0.25),
      shadeColor(color, -0.375),
      shadeColor(color, -0.5),
      shadeColor(color, -0.675),
      shadeColor(color, -0.7),
      shadeColor(color, -0.775),
  };
}
 
開發者ID:tateisu,項目名稱:SubwayTooter,代碼行數:17,代碼來源:ColorPickerDialog.java

示例7: getDarkColor

import android.support.annotation.ColorInt; //導入依賴的package包/類
/**
 * Get the dark color.
 *
 * @param color Original color.
 * @return Dark color.
 */
@ColorInt
private static int getDarkColor(final int color) {
    final float factor = 0.6f;

    final int a = Color.alpha(color);
    final int r = Math.round(Color.red(color) * factor);
    final int g = Math.round(Color.green(color) * factor);
    final int b = Math.round(Color.blue(color) * factor);
    return Color.argb(a,
            Math.min(r, 255),
            Math.min(g, 255),
            Math.min(b, 255));
}
 
開發者ID:kevalpatel2106,項目名稱:EmoticonGIFKeyboard,代碼行數:20,代碼來源:EmoticonGifImageView.java

示例8: setFillColor

import android.support.annotation.ColorInt; //導入依賴的package包/類
/**
 * Set a color to be drawn behind the circle-shaped drawable. Note that
 * this has no effect if the drawable is opaque or no drawable is set.
 *
 * @param fillColor The color to be drawn behind the drawable
 *
 * @deprecated Fill color support is going to be removed in the future
 */
@Deprecated
public void setFillColor(@ColorInt int fillColor) {
    if (fillColor == mFillColor) {
        return;
    }

    mFillColor = fillColor;
    mFillPaint.setColor(fillColor);
    invalidate();
}
 
開發者ID:tylersuehr7,項目名稱:chips-input-layout,代碼行數:19,代碼來源:CircleImageView.java

示例9: applySpan

import android.support.annotation.ColorInt; //導入依賴的package包/類
private void applySpan(Spannable spannable, @ColorInt int color, int start, int end) {
    spannable.setSpan(
            new ForegroundColorSpan(color),
            start,
            end,
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
 
開發者ID:solkin,項目名稱:minion-android,代碼行數:8,代碼來源:IniSyntaxHighlighter.java

示例10: getColor

import android.support.annotation.ColorInt; //導入依賴的package包/類
/**
 * Gets color.
 *
 * @param context  the context
 * @param colorRes the color res
 * @return the color
 */
@ColorInt
public static int getColor(Context context, @ColorRes int colorRes) {
    if (Build.VERSION.SDK_INT < 21) {
        //noinspection deprecation
        return context.getResources().getColor(colorRes);
    } else {
        return context.getResources().getColor(colorRes, null);
    }
}
 
開發者ID:mainh,項目名稱:MainCalendar,代碼行數:17,代碼來源:CompatUtils.java

示例11: calculateLuminance

import android.support.annotation.ColorInt; //導入依賴的package包/類
/**
 * Returns the luminance of a color as a float between {@code 0.0} and {@code 1.0}.
 * <p>Defined as the Y component in the XYZ representation of {@code color}.</p>
 */
@FloatRange(from = 0.0, to = 1.0)
public static double calculateLuminance(@ColorInt int color) {
    final double[] result = getTempDouble3Array();
    colorToXYZ(color, result);
    // Luminance is the Y component
    return result[1] / 100;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:ColorUtils.java

示例12: getColorFromAttr

import android.support.annotation.ColorInt; //導入依賴的package包/類
@ColorInt
public static int getColorFromAttr(Context context, int attr, @ColorInt int defaultColor) {
    TypedArray a = context.obtainStyledAttributes(new TypedValue().data, new int[]{attr});
    int intColor = a.getColor(0, defaultColor);
    a.recycle();
    return intColor;
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:8,代碼來源:Util.java

示例13: setFillColor

import android.support.annotation.ColorInt; //導入依賴的package包/類
public void setFillColor(@ColorInt int fillColor) {
    if (fillColor == mFillColor) {
        return;
    }

    mFillColor = fillColor;
    mFillPaint.setColor(fillColor);
    invalidate();
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:10,代碼來源:CircleImageView.java

示例14: setColorAlpha

import android.support.annotation.ColorInt; //導入依賴的package包/類
@ColorInt
public static int setColorAlpha(@ColorInt int color, @FloatRange(from = 0.0D, to = 1.0D) float alpha) {
    int alpha2 = Math.round((float) Color.alpha(color) * alpha);
    int red = Color.red(color);
    int green = Color.green(color);
    int blue = Color.blue(color);
    return Color.argb(alpha2, red, green, blue);
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:9,代碼來源:Helper.java

示例15: setColor

import android.support.annotation.ColorInt; //導入依賴的package包/類
/**
 * Sets the color of the drawable.
 */
public void setColor(@ColorInt int color) {
  if (color != mPaint.getColor()) {
    mPaint.setColor(color);
    invalidateSelf();
  }
}
 
開發者ID:commonsguy,項目名稱:cwac-crossport,代碼行數:10,代碼來源:DrawerArrowDrawable.java


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