本文整理匯總了Java中android.graphics.BlurMaskFilter.Blur方法的典型用法代碼示例。如果您正苦於以下問題:Java BlurMaskFilter.Blur方法的具體用法?Java BlurMaskFilter.Blur怎麽用?Java BlurMaskFilter.Blur使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.BlurMaskFilter
的用法示例。
在下文中一共展示了BlurMaskFilter.Blur方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.graphics.BlurMaskFilter; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blur_mask_filter);
LinearLayout container = (LinearLayout) findViewById(R.id.container);
for (BlurMaskFilter.Blur style : BlurMaskFilter.Blur.values()) {
TextView textView = new TextView(this);
textView.setTextAppearance(this, R.style.TextAppearance_Huge_Green);
applyFilter(textView, style);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER;
container.addView(textView, params);
}
}
示例2: init
import android.graphics.BlurMaskFilter; //導入方法依賴的package包/類
/**
* 初始化對象
*/
private void init(Context context) {
tipBitmaps = new ArrayList<>();
targetViews = new ArrayList<>();
rootView = ((Activity) getContext()).findViewById(android.R.id.content);
// 實例化畫筆並開啟其抗鋸齒和抗抖動
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
// 設置畫筆透明度為0是關鍵!
mPaint.setARGB(0, 255, 0, 0);
// 設置混合模式為DST_IN
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
BlurMaskFilter.Blur blurStyle = null;
switch (maskblurstyle) {
case MASKBLURSTYLE_SOLID:
blurStyle = BlurMaskFilter.Blur.SOLID;
break;
case MASKBLURSTYLE_NORMAL:
blurStyle = BlurMaskFilter.Blur.NORMAL;
break;
}
mPaint.setMaskFilter(new BlurMaskFilter(15, blurStyle));
// 生成前景圖Bitmap
fgBitmap = Bitmap.createBitmap(screenW, screenH, Bitmap.Config.ARGB_4444);
// 將其注入畫布
mCanvas = new Canvas(fgBitmap);
// 繪製前景畫布顏色
mCanvas.drawColor(maskColor);
// 實例化箭頭圖片
jtDownRight = BitmapFactory.decodeResource(getResources(), R.drawable.jt_down_right);
jtDownLeft = BitmapFactory.decodeResource(getResources(), R.drawable.jt_down_left);
jtUpLeft = BitmapFactory.decodeResource(getResources(), R.drawable.jt_up_left);
jtUpRight = BitmapFactory.decodeResource(getResources(), R.drawable.jt_up_right);
}
示例3: blur
import android.graphics.BlurMaskFilter; //導入方法依賴的package包/類
/**
* @see BlurMaskFilter#BlurMaskFilter(float, BlurMaskFilter.Blur)
*/
public static Span blur(final float radius, @NonNull final BlurMaskFilter.Blur style) {
return new Span(new SpanBuilder() {
@Override
public Object build() {
return new MaskFilterSpan(new BlurMaskFilter(radius, style));
}
});
}
示例4: blur
import android.graphics.BlurMaskFilter; //導入方法依賴的package包/類
public TextDecorator blur(final float radius, final BlurMaskFilter.Blur style, final String... texts) {
int index;
for (String text : texts) {
if (content.contains(text)) {
index = content.indexOf(text);
decoratedContent.setSpan(new MaskFilterSpan(new BlurMaskFilter(radius, style)), index, index + text.length(), flags);
}
}
return this;
}
示例5: applyFilter
import android.graphics.BlurMaskFilter; //導入方法依賴的package包/類
private void applyFilter(
TextView textView, BlurMaskFilter.Blur style) {
if (Build.VERSION.SDK_INT >= 11) {
ViewUtil.setSoftwareLayerType(textView);
}
textView.setText(style.name());
BlurMaskFilter filter = new BlurMaskFilter(textView.getTextSize() / 10, style);
textView.getPaint().setMaskFilter(filter);
}
示例6: addMaskFilterSpan
import android.graphics.BlurMaskFilter; //導入方法依賴的package包/類
/**
* @param density
* @param style BlurMaskFilter.Blur.NORMAL
* @return
*/
public SpanOptions addMaskFilterSpan(float density, BlurMaskFilter.Blur style) {
MaskFilterSpan span = new MaskFilterSpan(new BlurMaskFilter(density, style));
listSpan.add(span);
return this;
}
示例7: setBlur
import android.graphics.BlurMaskFilter; //導入方法依賴的package包/類
/**
* 設置模糊
* <p>尚存bug,其他地方存在相同的字體的話,相同字體出現在之前的話那麽就不會模糊,出現在之後的話那會一起模糊</p>
* <p>推薦還是把所有字體都模糊這樣使用</p>
*
* @param radius 模糊半徑(需大於0)
* @param style 模糊樣式<ul>
* <li>{@link BlurMaskFilter.Blur#NORMAL}</li>
* <li>{@link BlurMaskFilter.Blur#SOLID}</li>
* <li>{@link BlurMaskFilter.Blur#OUTER}</li>
* <li>{@link BlurMaskFilter.Blur#INNER}</li>
* </ul>
* @return {@link Builder}
*/
public Builder setBlur(float radius, BlurMaskFilter.Blur style) {
this.blurRadius = radius;
this.style = style;
this.isBlur = true;
return this;
}
示例8: drawMaskFilterSpan
import android.graphics.BlurMaskFilter; //導入方法依賴的package包/類
/**
* 模糊效果
*
* @param text
* @param density
* @param style BlurMaskFilter.Blur.NORMAL
* @return
*/
public AndroidSpan drawMaskFilterSpan(String text, float density, BlurMaskFilter.Blur style) {
MaskFilterSpan span = new MaskFilterSpan(new BlurMaskFilter(density, style));
drawSpan(text, span);
return this;
}