1.dp转px,下面工具类中的静态方法dp2px
public class DisplayUtils {
public static Point getScreenResolution(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point screenResolution = new Point();
if (android.os.Build.VERSION.SDK_INT >= 13) {
display.getSize(screenResolution);
} else {
screenResolution.set(display.getWidth(), display.getHeight());
}
return screenResolution;
}
public static int dp2px(Context context, float dpValue) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpValue, context.getResources().getDisplayMetrics());
}
}
2.在手机相册中隐藏某个文件夹中的图片文件,在此文件中创建一个.nomedia或者.outside文件(华为手机兼容)即可
szName = szName.substring(0, szName.length() - 1);
File folder = new File(outPathString + File.separator + szName);
folder.mkdirs();
if (szName.endsWith("imgs")) {
File nomedia = new File(folder.getPath(),".nomedia");
File outside = new File(folder.getPath(), ".outside");
try {
if(!nomedia.exists()) {
nomedia.createNewFile();
}
if (!outside.exists()) {
outside.createNewFile();
}
}catch (IOException e){
MLog.e("IOException","exception in unzip create nomedia file");
}
}