Android 人民币符号少一横问题解决方案

开发中会遇到人民币符号¥少一横的问题,可以复制以下羊角符号。

(1)复制“¥”使用这个字符。可行

(2)自定义组件,使用自带的字体(统一金额符号的显示)

public class MoneyTextView extends TextView{

    private static volatile Typeface moneyFont;

    public MoneyTextView(Context context) {
        this(context, null);
    }

    public MoneyTextView(Context context, AttributeSet attrs){
        super(context, attrs);
        setCustomFont(context);
    }

    private void setCustomFont(Context context) {
        if(moneyFont == null){
            synchronized(MoneyTextView.class){
                if(moneyFont == null){
                    AssetManager assertMgr = context.getAssets();
                    moneyFont = Typeface.createFromAsset(assertMgr, "fonts/money.otf");
                }
            }
        }
        setTypeface(moneyFont);
    }
}

猜你喜欢

转载自blog.csdn.net/T_yoo_csdn/article/details/82144267