当前位置: 首页>>代码示例>>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;未经允许,请勿转载。