List of usage examples for android.graphics.drawable GradientDrawable RADIAL_GRADIENT
int RADIAL_GRADIENT
To view the source code for android.graphics.drawable GradientDrawable RADIAL_GRADIENT.
Click Source Link
From source file:com.googlecode.eyesfree.widget.RadialMenuView.java
public RadialMenuView(Context context, RadialMenu menu, boolean useNodeProvider) { super(context); mRootMenu = menu;/*w ww.java 2 s. c o m*/ mRootMenu.setLayoutListener(mLayoutListener); mPaint = new Paint(); mPaint.setAntiAlias(true); mHandler = new LongPressHandler(context); mHandler.setListener(mLongPressListener); final SurfaceHolder holder = getHolder(); holder.setFormat(PixelFormat.TRANSLUCENT); holder.addCallback(mSurfaceCallback); final Resources res = context.getResources(); final ViewConfiguration config = ViewConfiguration.get(context); mSingleTapRadiusSq = config.getScaledTouchSlop(); // Dimensions. mInnerRadius = res.getDimensionPixelSize(R.dimen.inner_radius); mOuterRadius = res.getDimensionPixelSize(R.dimen.outer_radius); mCornerRadius = res.getDimensionPixelSize(R.dimen.corner_radius); mExtremeRadius = res.getDimensionPixelSize(R.dimen.extreme_radius); mSpacing = res.getDimensionPixelOffset(R.dimen.spacing); mTextSize = res.getDimensionPixelSize(R.dimen.text_size); mTextShadowRadius = res.getDimensionPixelSize(R.dimen.text_shadow_radius); mShadowRadius = res.getDimensionPixelSize(R.dimen.shadow_radius); // Colors. mOuterFillColor = res.getColor(R.color.outer_fill); mTextFillColor = res.getColor(R.color.text_fill); mCornerFillColor = res.getColor(R.color.corner_fill); mCornerTextFillColor = res.getColor(R.color.corner_text_fill); mDotFillColor = res.getColor(R.color.dot_fill); mDotStrokeColor = res.getColor(R.color.dot_stroke); mSelectionColor = res.getColor(R.color.selection_fill); mSelectionTextFillColor = res.getColor(R.color.selection_text_fill); mSelectionShadowColor = res.getColor(R.color.selection_shadow); mCenterFillColor = res.getColor(R.color.center_fill); mCenterTextFillColor = res.getColor(R.color.center_text_fill); mTextShadowColor = res.getColor(R.color.text_shadow); // Gradient colors. final int gradientInnerColor = res.getColor(R.color.gradient_inner); final int gradientOuterColor = res.getColor(R.color.gradient_outer); final int[] colors = new int[] { gradientInnerColor, gradientOuterColor }; mGradientBackground = new GradientDrawable(Orientation.TOP_BOTTOM, colors); mGradientBackground.setGradientType(GradientDrawable.RADIAL_GRADIENT); mGradientBackground.setGradientRadius(mExtremeRadius * 2.0f); final int subMenuOverlayColor = res.getColor(R.color.submenu_overlay); // Lighting filters generated from colors. mSubMenuFilter = new PorterDuffColorFilter(subMenuOverlayColor, PorterDuff.Mode.SCREEN); mInnerRadiusSq = (mInnerRadius * mInnerRadius); mExtremeRadiusSq = (mExtremeRadius * mExtremeRadius); mUseNodeProvider = useNodeProvider; if (mUseNodeProvider) { mTouchExplorer = new RadialMenuHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchExplorer); } // Corner shapes only need to be invalidated and cached once. initializeCachedShapes(); }
From source file:com.android.screenspeak.contextmenu.RadialMenuView.java
public RadialMenuView(Context context, RadialMenu menu, boolean useNodeProvider) { super(context); mRootMenu = menu;/* w ww . j a va 2s .c om*/ mRootMenu.setLayoutListener(new RadialMenu.MenuLayoutListener() { @Override public void onLayoutChanged() { invalidate(); } }); mPaint = new Paint(); mPaint.setAntiAlias(true); mHandler = new LongPressHandler(context); mHandler.setListener(new LongPressHandler.LongPressListener() { @Override public void onLongPress() { onItemLongPressed(mFocusedItem); } }); final SurfaceHolder holder = getHolder(); holder.setFormat(PixelFormat.TRANSLUCENT); holder.addCallback(new SurfaceHolder.Callback() { @Override public void surfaceCreated(SurfaceHolder holder) { mHolder = holder; } @Override public void surfaceDestroyed(SurfaceHolder holder) { mHolder = null; } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { invalidate(); } }); final Resources res = context.getResources(); final ViewConfiguration config = ViewConfiguration.get(context); mSingleTapRadiusSq = config.getScaledTouchSlop(); // Dimensions. mInnerRadius = res.getDimensionPixelSize(R.dimen.inner_radius); mOuterRadius = res.getDimensionPixelSize(R.dimen.outer_radius); mCornerRadius = res.getDimensionPixelSize(R.dimen.corner_radius); mExtremeRadius = res.getDimensionPixelSize(R.dimen.extreme_radius); mSpacing = res.getDimensionPixelOffset(R.dimen.spacing); mTextSize = res.getDimensionPixelSize(R.dimen.text_size); mTextShadowRadius = res.getDimensionPixelSize(R.dimen.text_shadow_radius); mShadowRadius = res.getDimensionPixelSize(R.dimen.shadow_radius); // Colors. mOuterFillColor = res.getColor(R.color.outer_fill); mTextFillColor = res.getColor(R.color.text_fill); mCornerFillColor = res.getColor(R.color.corner_fill); mCornerTextFillColor = res.getColor(R.color.corner_text_fill); mDotFillColor = res.getColor(R.color.dot_fill); mDotStrokeColor = res.getColor(R.color.dot_stroke); mSelectionColor = res.getColor(R.color.selection_fill); mSelectionTextFillColor = res.getColor(R.color.selection_text_fill); mSelectionShadowColor = res.getColor(R.color.selection_shadow); mCenterFillColor = res.getColor(R.color.center_fill); mCenterTextFillColor = res.getColor(R.color.center_text_fill); mTextShadowColor = res.getColor(R.color.text_shadow); // Gradient colors. final int gradientInnerColor = res.getColor(R.color.gradient_inner); final int gradientOuterColor = res.getColor(R.color.gradient_outer); final int[] colors = new int[] { gradientInnerColor, gradientOuterColor }; mGradientBackground = new GradientDrawable(Orientation.TOP_BOTTOM, colors); mGradientBackground.setGradientType(GradientDrawable.RADIAL_GRADIENT); mGradientBackground.setGradientRadius(mExtremeRadius * 2.0f); final int subMenuOverlayColor = res.getColor(R.color.submenu_overlay); // Lighting filters generated from colors. mSubMenuFilter = new PorterDuffColorFilter(subMenuOverlayColor, PorterDuff.Mode.SCREEN); mInnerRadiusSq = (mInnerRadius * mInnerRadius); mExtremeRadiusSq = (mExtremeRadius * mExtremeRadius); mUseNodeProvider = useNodeProvider; if (mUseNodeProvider) { // Lazily-constructed node provider helper. ViewCompat.setAccessibilityDelegate(this, new RadialMenuHelper(this)); } // Corner shapes only need to be invalidated and cached once. initializeCachedShapes(); }
From source file:com.bilibili.magicasakura.utils.GradientDrawableUtils.java
void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType) throws XmlPullParserException { TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[] { android.R.attr.gradientRadius }); TypedValue value = a.peekValue(0);//from w w w. j a v a 2s. co m if (value != null) { boolean radiusRel = value.type == TypedValue.TYPE_FRACTION; drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat()); } else if (gradientType == GradientDrawable.RADIAL_GRADIENT) { throw new XmlPullParserException( "<gradient> tag requires 'gradientRadius' " + "attribute with radial type"); } a.recycle(); }
From source file:com.bilibili.magicasakura.utils.GradientDrawableInflateImpl.java
void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType) throws XmlPullParserException { TypedArray a = DrawableUtils.obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[] { android.R.attr.gradientRadius }); TypedValue value = a.peekValue(0);/*from ww w . j a va2s. c o m*/ if (value != null) { boolean radiusRel = value.type == TypedValue.TYPE_FRACTION; drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat()); } else if (gradientType == GradientDrawable.RADIAL_GRADIENT) { throw new XmlPullParserException( "<gradient> tag requires 'gradientRadius' " + "attribute with radial type"); } a.recycle(); }
From source file:com.example.mapsv2.ClustersAreListsActivity.java
private void setSpotlight(float cx, float cy) { spotDrawable.setGradientCenter(cx, cy); // The following line is needed for Android 2.2 to flag it's state // as dirty and pick up the new gradient center set above. spotDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); }