Android碎知识点以及正则表达式

一、首行缩进2个字符:

"\u3000\u3000"

二、手机号和卡号中间省略:

"(\\d{4})\\d{10}(\\w{4})","$1*****$2" -->  4304*****7733

 "(\\d{3})\\d{4}(\\d{4})","$1****$2")  替换手机号

String phone1 = phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");


三、加载第三方字体:

public class FontUtil {


    public static Typeface getTypeface(Context context){
        Typeface TEXT_TYPE;
        try{
            TEXT_TYPE = Typeface.createFromAsset(context.getAssets(),"fronts/Impact.ttf");
        }catch(Exception e){
            Log.e("FontUtil", "加载第三方字体失败 ");
            TEXT_TYPE = null ;
        }
        return TEXT_TYPE;
    }
}


你可能感兴趣的:(Android)