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