美文网首页
Android ¥ 部分手机只显示一横

Android ¥ 部分手机只显示一横

作者: 天青色等Y雨 | 来源:发表于2020-01-05 11:34 被阅读0次
    /**
     * 设置带¥的字体,针对华为手机,只有一横
     *
     * @param addSpace 是否在¥和字体之间添加空格
     */
    public static void setMoneyText(TextView textView, boolean addSpace, String content) {
        String prefix = "¥";
        if (addSpace) {
            prefix = "¥ ";
        }
        // 要求版本24以上
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            prefix = Html.fromHtml("&yen", 0).toString();
            if (addSpace) {
                prefix = Html.fromHtml("&yen", 0).toString() + " ";
            }
        }
        if (TextUtils.isEmpty(content)) {
            textView.setText(prefix);
        } else {
            textView.setText(prefix + content);
        }
    }

相关文章

网友评论

      本文标题:Android ¥ 部分手机只显示一横

      本文链接:https://www.haomeiwen.com/subject/idvqactx.html