开发中会遇到人民币符号¥少一横的问题,可以复制以下羊角符号。
(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);
}
}