当前位置: 首页>>代码示例>>Java>>正文


Java ShapeDrawable.setShaderFactory方法代码示例

本文整理汇总了Java中android.graphics.drawable.ShapeDrawable.setShaderFactory方法的典型用法代码示例。如果您正苦于以下问题:Java ShapeDrawable.setShaderFactory方法的具体用法?Java ShapeDrawable.setShaderFactory怎么用?Java ShapeDrawable.setShaderFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.drawable.ShapeDrawable的用法示例。


在下文中一共展示了ShapeDrawable.setShaderFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createInnerStrokesDrawable

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private Drawable createInnerStrokesDrawable(final int color, float strokeWidth) {
  if (!mStrokeVisible) {
    return new ColorDrawable(Color.TRANSPARENT);
  }

  ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

  final int bottomStrokeColor = darkenColor(color);
  final int bottomStrokeColorHalfTransparent = halfTransparent(bottomStrokeColor);
  final int topStrokeColor = lightenColor(color);
  final int topStrokeColorHalfTransparent = halfTransparent(topStrokeColor);

  final Paint paint = shapeDrawable.getPaint();
  paint.setAntiAlias(true);
  paint.setStrokeWidth(strokeWidth);
  paint.setStyle(Style.STROKE);
  shapeDrawable.setShaderFactory(new ShaderFactory() {
    @Override
    public Shader resize(int width, int height) {
      return new LinearGradient(width / 2, 0, width / 2, height,
          new int[] { topStrokeColor, topStrokeColorHalfTransparent, color, bottomStrokeColorHalfTransparent, bottomStrokeColor },
          new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f },
          TileMode.CLAMP
      );
    }
  });

  return shapeDrawable;
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:30,代码来源:FloatingActionButtonLibrary.java

示例2: createInnerStrokesDrawable

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private Drawable createInnerStrokesDrawable(final int color, float strokeWidth) {
        if (!mStrokeVisible) {
                return new ColorDrawable(Color.TRANSPARENT);
        }

        ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

        final int bottomStrokeColor = darkenColor(color);
        final int bottomStrokeColorHalfTransparent = halfTransparent(bottomStrokeColor);
        final int topStrokeColor = lightenColor(color);
        final int topStrokeColorHalfTransparent = halfTransparent(topStrokeColor);

        final Paint paint = shapeDrawable.getPaint();
        paint.setAntiAlias(true);
        paint.setStrokeWidth(strokeWidth);
        paint.setStyle(Style.STROKE);
        shapeDrawable.setShaderFactory(new ShaderFactory() {
                @Override
                public Shader resize(int width, int height) {
                        return new LinearGradient(width / 2, 0, width / 2, height,
                                new int[]{topStrokeColor, topStrokeColorHalfTransparent, color, bottomStrokeColorHalfTransparent, bottomStrokeColor},
                                new float[]{0f, 0.2f, 0.5f, 0.8f, 1f},
                                TileMode.CLAMP
                        );
                }
        });

        return shapeDrawable;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:30,代码来源:FloatingActionButton.java

示例3: generateCircleDrawable

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private static Drawable generateCircleDrawable(final int color) {
    ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
    drawable.setShaderFactory(new ShaderFactory() {
        public Shader resize(int width, int height) {
            return new LinearGradient(0.0f, 0.0f, 0.0f, 0.0f, color, color, TileMode.REPEAT);
        }
    });
    return drawable;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:DayView.java


注:本文中的android.graphics.drawable.ShapeDrawable.setShaderFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。