Java Code Examples for android.graphics.drawable.GradientDrawable#setGradientType()

The following examples show how to use android.graphics.drawable.GradientDrawable#setGradientType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrawableHelper.java    From monero-wallet-android-app with MIT License 6 votes vote down vote up
/**
 * 创建一张圆角矩形的线性渐变图片
 *
 * @param startColor  开始颜色
 * @param endColor    结束颜色
 * @param radius      圆角大小
 * @param orientation 渐变方向
 * @return
 */
public static GradientDrawable getGradientDrawable(@ColorInt int startColor,
                                                   @ColorInt int endColor,
                                                   int radius,
                                                   GradientDrawable.Orientation orientation) {
    GradientDrawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setColors(new int[]{
            startColor,
            endColor
    });
    gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
    gradientDrawable.setOrientation(orientation);
    gradientDrawable.setShape(GradientDrawable.RECTANGLE);
    gradientDrawable.setCornerRadius(radius);
    return gradientDrawable;
}
 
Example 2
Source File: PaymentMethodFragment.java    From px-android with MIT License 6 votes vote down vote up
protected void tintBackground(@NonNull final ImageView background, @NonNull final String color) {
    final int backgroundColor = Color.parseColor(color);

    final int alpha = Color.alpha(backgroundColor);
    final int blue = Color.blue(backgroundColor);
    final int green = Color.green(backgroundColor);
    final int red = Color.red(backgroundColor);

    final int lighterBackgroundColor =
        Color.argb((int) (alpha * 0.7f), (int) (red * 0.8f), (int) (green * 0.8f), (int) (blue * 0.8f));
    Color.argb(0, 0, 0, 0);
    final int[] ints = { backgroundColor, lighterBackgroundColor };
    final GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.BL_TR,
        ints);

    gradientDrawable.setCornerRadius(getResources().getDimensionPixelSize(R.dimen.px_xs_margin));
    gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
    gradientDrawable.setShape(GradientDrawable.RECTANGLE);
    gradientDrawable.setDither(true);

    background.setImageDrawable(gradientDrawable);
}
 
Example 3
Source File: ImagePickerActivity.java    From titanium-imagepicker with Apache License 2.0 6 votes vote down vote up
private void drawBackground(View v, int color, boolean isCircle) {
		if (isCircle) {
        GradientDrawable gd = new GradientDrawable();
        gd.setGradientType(GradientDrawable.RADIAL_GRADIENT);
        gd.setColors(new int[]{color, Color.TRANSPARENT });
        gd.setGradientRadius((Defaults.IMAGE_HEIGHT - Defaults.CIRCLE_PADDING)/2);
        v.setBackground(gd);

    } else {
        ShapeDrawable oval = new ShapeDrawable (new OvalShape());
        oval.getPaint().setColor(color);
        v.setBackground(oval);
    }
}
 
Example 4
Source File: RMPAdapter.java    From Musicoco with Apache License 2.0 6 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.M)
private void bindImageAndForeground(View image, Bitmap bitmap) {
    if (bitmap == null) {
        bitmap = BitmapUtils.bitmapResizeFromResource(context.getResources(), R.drawable.default_song, imageWidth, imageHeight);
    }

    int defaultTC = Color.WHITE;
    int defaultBC = Color.GRAY;
    int[] colors = new int[4];
    ColorUtils.get4LightColorWithTextFormBitmap(bitmap, defaultBC, defaultTC, colors);

    int color = colors[0];
    color = color == defaultBC ? colors[2] : color;
    color = android.support.v4.graphics.ColorUtils.setAlphaComponent(color, 255);
    GradientDrawable dra = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT,
            new int[]{color, Color.TRANSPARENT});
    dra.setGradientType(GradientDrawable.LINEAR_GRADIENT);
    image.setBackground(dra);
}
 
Example 5
Source File: DrawUtils.java    From iMoney with Apache License 2.0 5 votes vote down vote up
public static GradientDrawable getDrawable(int rgb, float radius) {
    GradientDrawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(rgb);  //填充颜色
    gradientDrawable.setGradientType(GradientDrawable.RECTANGLE); // shape矩形
    gradientDrawable.setCornerRadius(radius);  //四周圆角半径
    gradientDrawable.setStroke(UIUtils.dp2px(1), rgb); //边框厚度与颜色
    return gradientDrawable;
}
 
Example 6
Source File: PageWidget.java    From fangzhuishushenqi with Apache License 2.0 5 votes vote down vote up
/**
 * 创建阴影的GradientDrawable
 */
private void createDrawable() {
    int[] color = {0x333333, 0xb0333333};
    mFolderShadowDrawableRL = new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, color);
    mFolderShadowDrawableRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFolderShadowDrawableLR = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, color);
    mFolderShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowColors = new int[]{0xff111111, 0x111111};
    mBackShadowDrawableRL = new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, mBackShadowColors);
    mBackShadowDrawableRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowDrawableLR = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowColors = new int[]{0x80111111, 0x111111};
    mFrontShadowDrawableVLR = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, mFrontShadowColors);
    mFrontShadowDrawableVLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);
    mFrontShadowDrawableVRL = new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, mFrontShadowColors);
    mFrontShadowDrawableVRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHTB = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, mFrontShadowColors);
    mFrontShadowDrawableHTB.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHBT = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, mFrontShadowColors);
    mFrontShadowDrawableHBT.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 7
Source File: CoverPageAnim.java    From NovelReader with MIT License 5 votes vote down vote up
public CoverPageAnim(int w, int h, View view, OnPageChangeListener listener) {
    super(w, h, view, listener);
    mSrcRect = new Rect(0, 0, mViewWidth, mViewHeight);
    mDestRect = new Rect(0, 0, mViewWidth, mViewHeight);
    int[] mBackShadowColors = new int[] { 0x66000000,0x00000000};
    mBackShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 8
Source File: CoverPageAnim.java    From HaoReader with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(int w, int h, PageView view, OnPageChangeListener listener) {
    super.init(w, h, view, listener);
    mSrcRect = new Rect(0, 0, mViewWidth, mViewHeight);
    mDestRect = new Rect(0, 0, mViewWidth, mViewHeight);
    int[] mBackShadowColors = new int[]{0x66111111, 0x00000000};
    mBackShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 9
Source File: ShapeUse.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
public static void shapeUse() {
    Button vid_btn1 = null;

    // 默认就设置背景色
    ShapeUtils.Builder builder = new ShapeUtils.Builder();
    builder.setRadiusLeft(10f).setColor(R.color.black);
    ViewUtils.setBackground(vid_btn1, builder.build().getDrawable());

    // 设置点击效果
    GradientDrawable drawable1 = ShapeUtils.newBuilder(10f, R.color.black).setStroke(5, R.color.green).build().getDrawable();
    GradientDrawable drawable2 = ShapeUtils.newBuilder(10f, R.color.sky_blue).setStroke(5, R.color.gray).build().getDrawable();

    ViewUtils.setBackground(vid_btn1, StateListUtils.newSelector(drawable2, drawable1)); // 设置点击 View 背景变色, 不用写 shape xml 文件
    vid_btn1.setTextColor(StateListUtils.createColorStateList(R.color.red, R.color.white)); // 设置点击字体变色

    // 设置渐变
    View vid_view1 = null;
    // int[] colors = new int[]{ Color.RED, Color.BLUE, Color.GREEN };

    int[] colors = new int[3];
    colors[0] = ContextCompat.getColor(DevUtils.getContext(), R.color.black);
    colors[1] = ContextCompat.getColor(DevUtils.getContext(), R.color.sky_blue);
    colors[2] = ContextCompat.getColor(DevUtils.getContext(), R.color.orange);

    // ShapeUtils.newBuilderToGradient(GradientDrawable.Orientation.BR_TL, colors).build().setDrawable(vid_view1);

    GradientDrawable drawable = ShapeUtils.newBuilderToGradient(GradientDrawable.Orientation.BR_TL, colors).build().getDrawable();
    // drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); // 线性渐变, 这是默认设置
    // drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); // 放射性渐变, 以开始色为中心
    drawable.setGradientType(GradientDrawable.SWEEP_GRADIENT); // 扫描线式的渐变
    ViewUtils.setBackground(vid_view1, drawable);
}
 
Example 10
Source File: BookPageView.java    From CrawlerForReader with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化各区域阴影GradientDrawable
 */
private void createGradientDrawable() {
    int deepColor = 0x33333333;
    int lightColor = 0x01333333;
    int[] gradientColors = new int[]{lightColor, deepColor};//渐变颜色数组
    drawableLeftTopRight = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, gradientColors);
    drawableLeftTopRight.setGradientType(GradientDrawable.LINEAR_GRADIENT);
    drawableLeftLowerRight = new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, gradientColors);
    drawableLeftLowerRight.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    deepColor = 0x22333333;
    lightColor = 0x01333333;
    gradientColors = new int[]{deepColor, lightColor, lightColor};
    drawableRightTopRight = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, gradientColors);
    drawableRightTopRight.setGradientType(GradientDrawable.LINEAR_GRADIENT);
    drawableRightLowerRight = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, gradientColors);
    drawableRightLowerRight.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    deepColor = 0x44333333;
    lightColor = 0x01333333;
    gradientColors = new int[]{lightColor, deepColor};//渐变颜色数组
    drawableHorizontalLowerRight = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, gradientColors);
    drawableHorizontalLowerRight.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    deepColor = 0x55111111;
    lightColor = 0x00111111;
    gradientColors = new int[]{deepColor, lightColor};//渐变颜色数组
    drawableBTopRight = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, gradientColors);
    drawableBTopRight.setGradientType(GradientDrawable.LINEAR_GRADIENT);//线性渐变
    drawableBLowerRight = new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, gradientColors);
    drawableBLowerRight.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    deepColor = 0x55333333;
    lightColor = 0x00333333;
    gradientColors = new int[]{lightColor, deepColor};//渐变颜色数组
    drawableCTopRight = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, gradientColors);
    drawableCTopRight.setGradientType(GradientDrawable.LINEAR_GRADIENT);
    drawableCLowerRight = new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, gradientColors);
    drawableCLowerRight.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 11
Source File: OverlapSlider.java    From CrawlerForReader with Apache License 2.0 5 votes vote down vote up
public OverlapSlider() {
    mPath = new Path();

    int[] mBackShadowColors = new int[]{0xaa666666, 0x666666};

    mShadowDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    mShadowDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 12
Source File: Drawables.java    From noDrawable with Apache License 2.0 4 votes vote down vote up
public static Drawable create(
        @ShapeMode int shapeMode, @ColorInt Integer solidColor,
        @ColorInt int strokeColor, @DP float strokeWidth, @DP float strokeDash, @DP float strokeDashGap,
        @DP float radius, @DP float radiusLT, @DP float radiusLB, @DP float radiusRT, @DP float radiusRB,
        @ColorInt Integer startColor, @ColorInt Integer centerColor, @ColorInt Integer endColor,
        @Orientation int orientation, @GradientType int gradientType,
        Float radialCenterX, Float radialCenterY, float radialRadius,
        @DP float width, @DP float height,
        @DP float marginLeft, @DP float marginTop, @DP float marginRight, @DP float marginBottom,
        @DP float ringThickness,
        @DP float   ringThicknessRatio,
        @DP float ringInnerRadius,
        @DP float   ringInnerRadiusRatio
) {
    if (shapeMode == INVALID && solidColor == null && strokeColor == INVALID
            && strokeWidth == INVALID && strokeDash == INVALID && strokeDashGap == INVALID
            && radius == INVALID && radiusLT == INVALID && radiusLB == INVALID
            && radiusRT == INVALID && radiusRB == INVALID && startColor == null
            && centerColor == null && endColor == null && orientation == INVALID
            && gradientType == INVALID && radialCenterX == null && radialCenterY == null
            && radialRadius == INVALID && width == INVALID && height == INVALID
            && marginLeft == INVALID && marginTop == INVALID && marginRight == INVALID && marginBottom == INVALID
            ) {
        // 这里需要判断empty,因为有可能只设置了一个state的drawable,那么其他state的就是empty了
        return null;
    }
    GradientDrawable drawable = new GradientDrawable();
    if (startColor != null && endColor != null) {
        int[] colors;
        if (centerColor != null) {
            colors = new int[3];
            colors[0] = startColor;
            colors[1] = centerColor;
            colors[2] = endColor;
        } else {
            colors = new int[2];
            colors[0] = startColor;
            colors[1] = endColor;
        }
        drawable.setColors(colors);
        drawable.setOrientation(mapOrientation(orientation));
        drawable.setGradientType(gradientType);
        if (gradientType == GradientType.RADIAL) {
            drawable.setGradientCenter(radialCenterX == null ? .5f : radialCenterX,
                    radialCenterY == null ? .5f : radialCenterY);
            drawable.setGradientRadius(dip2px(radialRadius));
        }
    } else {
        if (solidColor != null) {
            drawable.setColor(solidColor);
        }
    }
    drawable.setShape(validShapeMode(shapeMode));
    if (shapeMode == ShapeMode.RING) {
        // 由于GradientDrawable中没有ring相关的公开API,所以使用反射,若对性能有要求,请注意。
        setRingValue(drawable, ringThickness, ringThicknessRatio, ringInnerRadius, ringInnerRadiusRatio);
    }
    if (strokeWidth > 0) {
        drawable.setStroke(dip2px(strokeWidth), strokeColor, dip2px(strokeDash), dip2px(strokeDashGap));
    }
    if (radius <= 0) {
        float[] radiusEach = new float[]{dip2px(radiusLT), dip2px(radiusLT), dip2px(radiusRT), dip2px(radiusRT),
                dip2px(radiusRB), dip2px(radiusRB), dip2px(radiusLB), dip2px(radiusLB)};
        drawable.setCornerRadii(radiusEach);
    } else {
        drawable.setCornerRadius(dip2px(radius));
    }
    if (width > 0 && height > 0) {
        // https://stackoverflow.com/a/29180660/4698946
        drawable.setSize(dip2px(width), dip2px(height));
    }
    if (marginLeft != 0 || marginTop != 0 || marginRight != 0 || marginBottom != 0) {
        return new InsetDrawable(drawable,
                dip2px(marginLeft),
                dip2px(marginTop),
                dip2px(marginRight),
                dip2px(marginBottom));
    } else {
        return drawable;
    }
}
 
Example 13
Source File: QButton.java    From QButton with MIT License 4 votes vote down vote up
public GradientDrawable getDrawable1(int backgroundColor, float radius) {

        int colors[] = {backgroundColor,
                manipulateColor(backgroundColor, 0.8f)};

        GradientDrawable shape = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, colors);

        shape.setShape(GradientDrawable.RECTANGLE);
        shape.setCornerRadius(radius);

        shape.setGradientType(GradientDrawable.LINEAR_GRADIENT);

        shape.setStroke(mStrokeWidth, mStrokeColor);
        if (mStrokeDashGap > 0 || mStrokeDashWidth > 0) {
            shape.setStroke(mStrokeWidth, mStrokeColor, mStrokeDashWidth, mStrokeDashGap);
        }

        return shape;
    }
 
Example 14
Source File: PageWidget.java    From coolreader with MIT License 4 votes vote down vote up
/**
 *  创建阴影的GradientDrawable
 */
private void createDrawable() {
	int[] color = { 0x333333, 0xb0333333 };
	mFolderShadowDrawableRL = new GradientDrawable(
			GradientDrawable.Orientation.RIGHT_LEFT, color);
	mFolderShadowDrawableRL
			.setGradientType(GradientDrawable.LINEAR_GRADIENT);

	mFolderShadowDrawableLR = new GradientDrawable(
			GradientDrawable.Orientation.LEFT_RIGHT, color);
	mFolderShadowDrawableLR
			.setGradientType(GradientDrawable.LINEAR_GRADIENT);

	mBackShadowColors = new int[] { 0xff111111, 0x111111 };
	mBackShadowDrawableRL = new GradientDrawable(
			GradientDrawable.Orientation.RIGHT_LEFT, mBackShadowColors);
	mBackShadowDrawableRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

	mBackShadowDrawableLR = new GradientDrawable(
			GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
	mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);

	mFrontShadowColors = new int[] { 0x80111111, 0x111111 };
	mFrontShadowDrawableVLR = new GradientDrawable(
			GradientDrawable.Orientation.LEFT_RIGHT, mFrontShadowColors);
	mFrontShadowDrawableVLR
			.setGradientType(GradientDrawable.LINEAR_GRADIENT);
	mFrontShadowDrawableVRL = new GradientDrawable(
			GradientDrawable.Orientation.RIGHT_LEFT, mFrontShadowColors);
	mFrontShadowDrawableVRL
			.setGradientType(GradientDrawable.LINEAR_GRADIENT);

	mFrontShadowDrawableHTB = new GradientDrawable(
			GradientDrawable.Orientation.TOP_BOTTOM, mFrontShadowColors);
	mFrontShadowDrawableHTB
			.setGradientType(GradientDrawable.LINEAR_GRADIENT);

	mFrontShadowDrawableHBT = new GradientDrawable(
			GradientDrawable.Orientation.BOTTOM_TOP, mFrontShadowColors);
	mFrontShadowDrawableHBT
			.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 15
Source File: FlipView.java    From eBook with Apache License 2.0 4 votes vote down vote up
private void initObjects() {

        mTouch = new PointF();
        mCorner = new PointF();
        mLastDownPoint = new PointF();

        mBezierStart1 = new PointF();
        mBezierControl1 = new PointF();
        mBezierEnd1 = new PointF();
        mBezierVertex1 = new PointF();

        mBezierStart2 = new PointF();
        mBezierControl2 = new PointF();
        mBezierEnd2 = new PointF();
        mBezierVertex2 = new PointF();

        mAutoSlideStart = new PointF();

        mFoldPaint = new Paint();
        mFoldPaint.setAntiAlias(true);
        mFoldPaint.setAlpha(0x70);

        mFoldPath = new Path();
        mFoldAndNextPath = new Path();

        mSlideHandler = new SlideHandler();

        //初始化阴影GradientDrawable
        int[] frontShadowColors = new int[]{0x80111111, 0x00111111};//从深到浅
        mCurShadowRL = new GradientDrawable(
                GradientDrawable.Orientation.RIGHT_LEFT, frontShadowColors);
        mCurShadowRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

        mCurShadowBT = new GradientDrawable(
                GradientDrawable.Orientation.BOTTOM_TOP, frontShadowColors);
        mCurShadowBT.setGradientType(GradientDrawable.LINEAR_GRADIENT);

        mCurShadowTB = new GradientDrawable(
                GradientDrawable.Orientation.TOP_BOTTOM, frontShadowColors);
        mCurShadowTB.setGradientType(GradientDrawable.LINEAR_GRADIENT);


        int[] color = {0x00333333, 0xb0333333}; //从浅到深
        mFoldShadowRL = new GradientDrawable(
                GradientDrawable.Orientation.RIGHT_LEFT, color);
        mFoldShadowRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

        mFoldShadowLR = new GradientDrawable(
                GradientDrawable.Orientation.LEFT_RIGHT, color);
        mFoldShadowLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);


        int[] nextShadowColors = new int[]{0xff111111, 0x00111111}; //从深到浅
        mNextShadowRL = new GradientDrawable(
                GradientDrawable.Orientation.RIGHT_LEFT, nextShadowColors);
        mNextShadowRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);


        mNextShadowLR = new GradientDrawable(
                GradientDrawable.Orientation.LEFT_RIGHT, nextShadowColors);
        mNextShadowLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);
    }
 
Example 16
Source File: PageWidget.java    From Jreader with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建阴影的GradientDrawable
 */
private void createDrawable() {
    int[] color = { 0x333333, 0xb0333333 };
    mFolderShadowDrawableRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, color);
    mFolderShadowDrawableRL
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFolderShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, color);
    mFolderShadowDrawableLR
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowColors = new int[] { 0xff111111, 0x111111 };
    mBackShadowDrawableRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, mBackShadowColors);
    mBackShadowDrawableRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowColors = new int[] { 0x80111111, 0x111111 };
    mFrontShadowDrawableVLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mFrontShadowColors);
    mFrontShadowDrawableVLR
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);
    mFrontShadowDrawableVRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, mFrontShadowColors);
    mFrontShadowDrawableVRL
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHTB = new GradientDrawable(
            GradientDrawable.Orientation.TOP_BOTTOM, mFrontShadowColors);
    mFrontShadowDrawableHTB
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHBT = new GradientDrawable(
            GradientDrawable.Orientation.BOTTOM_TOP, mFrontShadowColors);
    mFrontShadowDrawableHBT
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 17
Source File: pageView.java    From Jreader with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建阴影的GradientDrawable
 */
private void createDrawable() {
    int[] color = { 0x333333, 0xb0333333 };
    mFolderShadowDrawableRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, color);
    mFolderShadowDrawableRL
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFolderShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, color);
    mFolderShadowDrawableLR
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowColors = new int[] { 0xff111111, 0x111111 };
    mBackShadowDrawableRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, mBackShadowColors);
    mBackShadowDrawableRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowColors = new int[] { 0x80111111, 0x111111 };
    mFrontShadowDrawableVLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mFrontShadowColors);
    mFrontShadowDrawableVLR
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);
    mFrontShadowDrawableVRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, mFrontShadowColors);
    mFrontShadowDrawableVRL
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHTB = new GradientDrawable(
            GradientDrawable.Orientation.TOP_BOTTOM, mFrontShadowColors);
    mFrontShadowDrawableHTB
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHBT = new GradientDrawable(
            GradientDrawable.Orientation.BOTTOM_TOP, mFrontShadowColors);
    mFrontShadowDrawableHBT
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 18
Source File: SimulationPageAnim.java    From FriendBook with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 创建阴影的GradientDrawable
 */
private void createDrawable() {
    int[] color = { 0x333333, 0xb0333333 };
    mFolderShadowDrawableRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, color);
    mFolderShadowDrawableRL
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFolderShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, color);
    mFolderShadowDrawableLR
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowColors = new int[] { 0xff111111, 0x111111 };
    mBackShadowDrawableRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, mBackShadowColors);
    mBackShadowDrawableRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowColors = new int[] { 0x80111111, 0x111111 };
    mFrontShadowDrawableVLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mFrontShadowColors);
    mFrontShadowDrawableVLR
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);
    mFrontShadowDrawableVRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, mFrontShadowColors);
    mFrontShadowDrawableVRL
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHTB = new GradientDrawable(
            GradientDrawable.Orientation.TOP_BOTTOM, mFrontShadowColors);
    mFrontShadowDrawableHTB
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHBT = new GradientDrawable(
            GradientDrawable.Orientation.BOTTOM_TOP, mFrontShadowColors);
    mFrontShadowDrawableHBT
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 19
Source File: SimulationPageAnim.java    From a with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 创建阴影的GradientDrawable
 */
private void createDrawable() {
    int[] color = {0x333333, 0xb0333333};
    mFolderShadowDrawableRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, color);
    mFolderShadowDrawableRL
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFolderShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, color);
    mFolderShadowDrawableLR
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowColors = new int[]{0xff111111, 0x111111};
    mBackShadowDrawableRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, mBackShadowColors);
    mBackShadowDrawableRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mBackShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
    mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowColors = new int[]{0x80111111, 0x111111};
    mFrontShadowDrawableVLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT, mFrontShadowColors);
    mFrontShadowDrawableVLR
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);
    mFrontShadowDrawableVRL = new GradientDrawable(
            GradientDrawable.Orientation.RIGHT_LEFT, mFrontShadowColors);
    mFrontShadowDrawableVRL
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHTB = new GradientDrawable(
            GradientDrawable.Orientation.TOP_BOTTOM, mFrontShadowColors);
    mFrontShadowDrawableHTB
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);

    mFrontShadowDrawableHBT = new GradientDrawable(
            GradientDrawable.Orientation.BOTTOM_TOP, mFrontShadowColors);
    mFrontShadowDrawableHBT
            .setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
 
Example 20
Source File: fwSelectorView.java    From SensorTag-CC2650 with Apache License 2.0 4 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder fwDialog = new AlertDialog.Builder(getActivity())
            .setTitle("Select Factory FW")
            .setNegativeButton("Cancel", null);

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View fwView = inflater.inflate(R.layout.fw_selector, null);

    table = (TableLayout) fwView.findViewById(R.id.fwentries_layout);
    table.removeAllViews();
    /* Initialize view from file */
    if (this.firmwares != null) {
        for(int ii = 0; ii < this.firmwares.size(); ii++) {
            tiFirmwareEntry entry = this.firmwares.get(ii);
            if (entry.RequiredVersionRev > cFW) {
                entry.compatible = false;
            }
            if (entry.Version < cFW) {
                entry.compatible = false;
            }
            final firmwareEntryTableRow tRow = new firmwareEntryTableRow(getActivity(),entry);
            GradientDrawable g = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
                    new int[] { Color.WHITE, Color.LTGRAY});
            g.setGradientType(GradientDrawable.LINEAR_GRADIENT);
            StateListDrawable states = new StateListDrawable();
            states.addState(new int[] {android.R.attr.state_pressed,-android.R.attr.state_selected},g);

            tRow.setBackgroundDrawable(states);
            tRow.position = ii;
            tRow.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.d("fwSelectorView", "Firmware cell clicked");
                    final Intent intent = new Intent(ACTION_FW_WAS_SELECTED);
                    intent.putExtra(EXTRA_SELECTED_FW_INDEX,tRow.position);
                    getActivity().sendBroadcast(intent);
                    dismiss();
                }
            });
            if (entry.compatible == true)tRow.setGrayedOut(false);
            else tRow.setGrayedOut(true);
            table.addView(tRow);
            table.requestLayout();

        }

    }
    fwDialog.setView(fwView);
    Dialog fwSelectorDialog = fwDialog.create();
    return fwSelectorDialog;
}