本文整理汇总了Java中android.graphics.drawable.GradientDrawable.setGradientType方法的典型用法代码示例。如果您正苦于以下问题:Java GradientDrawable.setGradientType方法的具体用法?Java GradientDrawable.setGradientType怎么用?Java GradientDrawable.setGradientType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.GradientDrawable
的用法示例。
在下文中一共展示了GradientDrawable.setGradientType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OverlappedWidget
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public OverlappedWidget(Context context, String bookId,
List<BookMixAToc.mixToc.Chapters> chaptersList,
OnReadStateChangeListener listener) {
super(context, bookId, chaptersList, listener);
mTouch.x = 0.01f;
mTouch.y = 0.01f;
mPath0 = new Path();
int[] mBackShadowColors = new int[]{0xaa666666, 0x666666};
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);
}
示例2: CoverPageAnim
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
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);
}
示例3: init
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void init(Context context){
defaultWidth = 600;
defaultHeight = 1000;
pageNum = 1;
scrollPageLeft = 0;
scrollTime = 300;
touchStyle = TOUCH_RIGHT;
pageState = PAGE_STAY;
touchPoint = new MyPoint(-1,-1);
mScroller = new Scroller(context,new LinearInterpolator());
int[] mBackShadowColors = new int[] { 0x66000000,0x00000000};
shadowDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
shadowDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
示例4: bindImageAndForeground
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@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);
}
示例5: initBorder
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void initBorder() {
// if (mWipeOffBorder || mIdentity == null || !mIdentity.officialMember) {
// mDrawable = null;
// setBackground(null);
// return;
// }
if (mDrawable == null) {
float radius = 4f;
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
gradientDrawable.setShape(GradientDrawable.RECTANGLE);
gradientDrawable.setDither(true);
gradientDrawable.setStroke(STROKE_SIZE, mColor);
gradientDrawable.setCornerRadius(radius);
mDrawable = gradientDrawable;
} else {
mDrawable.setStroke(STROKE_SIZE, mColor);
}
setBackground(mDrawable);
}
示例6: createCircleGradientDrawable
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
* 创建一张渐变图片,支持韵脚。
*
* @param startColor 渐变开始色
* @param endColor 渐变结束色
* @param radius 圆角大小
* @param centerX 渐变中心点 X 轴坐标
* @param centerY 渐变中心点 Y 轴坐标
* @return 返回所创建的渐变图片。
*/
@TargetApi(16)
public static GradientDrawable createCircleGradientDrawable(@ColorInt int startColor,
@ColorInt int endColor, int radius,
@FloatRange(from = 0f, to = 1f) float centerX,
@FloatRange(from = 0f, to = 1f) float centerY) {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColors(new int[]{
startColor,
endColor
});
gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
gradientDrawable.setGradientRadius(radius);
gradientDrawable.setGradientCenter(centerX, centerY);
return gradientDrawable;
}
示例7: initBackground
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void initBackground() {
GradientDrawable.Orientation orientation = getOrientation();
GradientDrawable drawable = new GradientDrawable(orientation, new int[]{bgGradientStart, bgGradientCenter, bgGradientEnd});
drawable.setShape(GradientDrawable.RECTANGLE);
drawable.setCornerRadius(dialogRadius);
switch (bgGradientType) {
case GRADIENT_RADIAL:
drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
break;
case GRADIENT_SWEEP:
drawable.setGradientType(GradientDrawable.SWEEP_GRADIENT);
break;
default:
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
break;
}
if (isHalloween) {
drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
drawable.setGradientRadius(getContext().getResources().getDimensionPixelSize(R.dimen.dialog_height) / 2);
} else {
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
root.setBackground(drawable);
} else {
root.setBackgroundDrawable(drawable);
}
}
示例8: createDrawable
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
* 创建阴影的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);
}
示例9: create
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public static GradientDrawable create(@ColorInt int startColor, @ColorInt int endColor, int radius,
@FloatRange(from = 0f, to = 1f) float centerX,
@FloatRange(from = 0f, to = 1f) float centerY) {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColors(new int[]{
startColor,
endColor
});
gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
gradientDrawable.setGradientRadius(radius);
gradientDrawable.setGradientCenter(centerX, centerY);
return gradientDrawable;
}
示例10: onViewCreated
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@Override
protected void onViewCreated() {
//蓝色线性渐变色背景
GradientDrawable drawable = new GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM, new int[]{0xFF5b7ef0, 0xFF6687f2});
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
titleBar.setBackgroundDrawable(drawable);
//蓝色纯色背景
// titleBar.setBackgroundColor(getContext().getResources().getColor(ResHelper.getColorRes(getContext(), "bbs_theme0_blue")));
}
示例11: drawBackground
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
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);
}
}
示例12: createDrawable
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
* 创建阴影的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);
}
示例13: createDrawable
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void createDrawable() {
int[] color = { 0x333333, 0xB0333333 };
mFolderDrawableRL = new GradientDrawable(
GradientDrawable.Orientation.RIGHT_LEFT, color);
mFolderDrawableRL
.setGradientType(GradientDrawable.LINEAR_GRADIENT);
mFolderDrawableLR = new GradientDrawable(
GradientDrawable.Orientation.LEFT_RIGHT, color);
mFolderDrawableLR
.setGradientType(GradientDrawable.LINEAR_GRADIENT);
mBackShadowColors = new int[] { 0xFF111111, 0x111111 };
mBackDrawableRL = new GradientDrawable(
GradientDrawable.Orientation.RIGHT_LEFT, mBackShadowColors);
mBackDrawableRL.setGradientType(GradientDrawable.LINEAR_GRADIENT);
mBackDrawableLR = new GradientDrawable(
GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
mBackDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);
mFrontShadowColors = new int[] { 0x80111111, 0x111111 };
mFrontDrawable_v_lr = new GradientDrawable(
GradientDrawable.Orientation.LEFT_RIGHT, mFrontShadowColors);
mFrontDrawable_v_lr
.setGradientType(GradientDrawable.LINEAR_GRADIENT);
mFrontDrawable_v_rl = new GradientDrawable(
GradientDrawable.Orientation.RIGHT_LEFT, mFrontShadowColors);
mFrontDrawable_v_rl
.setGradientType(GradientDrawable.LINEAR_GRADIENT);
mFrontDrawable_h_tb = new GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM, mFrontShadowColors);
mFrontDrawable_h_tb
.setGradientType(GradientDrawable.LINEAR_GRADIENT);
mFrontDrawble_h_bt = new GradientDrawable(
GradientDrawable.Orientation.BOTTOM_TOP, mFrontShadowColors);
mFrontDrawble_h_bt
.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}