持續更新...
用于進行dip和px轉換:
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
用于進行px和dip轉換
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
檢測一段文字中是否含有某個詞匯
public static boolean isHaveWord(String original,String haveWord){
boolean flag=false;
String replaceStr=original;
if ((replaceStr.replaceAll(haveWord,"")).length()!=original.length()){
flag=true;
}
return flag;
}