适配底部导航栏
第一步,打开需要适配的导航栏布局,添加:
android:fitsSystemWindows="true"
第二步,去对应的Activity ,在Activity中添加,放在setContentView之后执行
Glide 3.7 加载圆角imageView
加载圆角imageView 自定义类
package com.hunan.juyan.utils;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.*;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.hunan.juyan.utils.alipayutil.Alipay;
/**
* Glide 加载圆角自定义属性
*/
public class GlideRoundTransformUtils extends BitmapTransformation {
private static float radius = 0.0f;
public GlideRoundTransformUtils(Context context) {
this(context, 4);
}
public GlideRoundTransformUtils(Context context, int dp) {
super(context);
radius = Resources.getSystem().getDisplayMetrics().density * dp;
}
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
return roundCorp(pool, toTransform);
}
private static Bitmap roundCorp(BitmapPool pool, Bitmap source) {
if (source == null) return null;
Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
canvas.drawRoundRect(rectF, radius, radius, paint);
return result;
}
@Override
public String getId() {
return getClass().getName() + Math.round(radius);
}
}
使用Glide 加载圆角的使用方式:
Glide.with(context).load("路径").transform(new CenterCrop(getContext()), new GlideRoundTransformUtils(getContext())).placeholder(R.mipmap.local_image)// 加载错误图
.crossFade()
.error(R.mipmap.local_image).into(itemView);
判断字符串中出现字母的数量
/**
* 获取当前字符串中是否包含数字或字母以及个数
*
* @param text
* @return
*/
public static int getNumAndChatSize(String text) {
int result = 0;
for (int i = 0; i < text.length(); i++) {
Pattern p = Pattern.compile("[a-zA-Z0-9]");
Matcher m = p.matcher(text.charAt(i) + "");
if (m.matches()) {
++result;
}
}
return result;
}
判断字符串中连续出现的字母数量是否超过五个
/**
* 判断字符串中连续出现的字母数量是否超过五个
* @param text
* @return 是否超过五个数,true 超过五个数,
* false 未超过五个数
* */
public static boolean getNumAndChatContinuous(String text) {
int result = 0;
for (int i = 0; i < text.length(); i++) {
Pattern p = Pattern.compile("[a-zA-Z0-9]");
Matcher m = p.matcher(text.charAt(i) + "");
if (m.matches()) {
++result;
} else {
result = 0;
}
if (result > 4) {
return true;
}
}
return false;
}
处理General error during semantic analysis: Unsupported class file major version 57此种问题
具体的报错日志如下:
Gradle sync failed: startup failed:
General error during semantic analysis: Unsupported class file major version 57
java.lang.IllegalArgumentException: Unsupported class file major version 57
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:184)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:166)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:152)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:273)
at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81)
at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:254)
at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:192)
at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:172)
at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:128)
at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveCl... (show balloon)
可以去File->Project Structuer中查看当前导入的项目中使用的SDK版本是否与之前项目匹配的相同,如果不相同修改为相同版本即可
网友评论