當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。