android中出现不正确的美元符号

时间:2015-09-14 08:06:25

标签: java android

我正在以编程方式将$ sign添加到textview文本中,但显示不正确,正如您在附加的屏幕截图中看到的那样。我希望它像键盘的正常美元符号,而不是这个Android键盘的美元符号。

 if (prices != null && prices.getRegularPrice() != null) {
        holder.mOriginalPriceTextView.setVisibility(View.VISIBLE);
        float originalMinPrice = prices.getRegularPrice().getMinPrice();
        float originalMaxPrice = prices.getRegularPrice().getMaxPrice();

        StringBuilder originalPriceString = new StringBuilder();
        if (originalMaxPrice != 0.0 && originalMaxPrice > originalMinPrice) {
            if (null != prices.getRegularPriceType()) {
                originalPriceString.append(prices.getRegularPriceType());
            }
            originalPriceString.append(" $");
            String originalMinPriceValue = UtilityMethods.getDecimalFormattedText(
                    (double) originalMinPrice);
            if (!TextUtils.isEmpty(originalMinPriceValue)) {
                originalPriceString.append(originalMinPriceValue);
            } else {
                originalPriceString.append(originalMinPrice);
            }
            originalPriceString.append(" - ");
            originalPriceString.append(" $");
            String originalMaxPriceValue = UtilityMethods.getDecimalFormattedText(
                    (double) originalMaxPrice);
            if (!TextUtils.isEmpty(originalMaxPriceValue)) {
                originalPriceString.append(originalMaxPriceValue);
            } else {
                originalPriceString.append(originalMaxPrice);
            }
            holder.mOriginalPriceTextView.setTypeface(null, Typeface.NORMAL);
            holder.mOriginalPriceTextView.setTextColor(mActivity.get()
                    .getResources().getColor(R.color.pmp_original_text));
            holder.mOriginalPriceTextView.setText(originalPriceString);
        } else {
            if (null != prices.getRegularPriceType()) {
                originalPriceString.append(prices.getRegularPriceType());
            }
            originalPriceString.append(" $");
            String originalMinPriceValue = UtilityMethods.getDecimalFormattedText(
                    (double) originalMinPrice);
            if (!TextUtils.isEmpty(originalMinPriceValue)) {
                originalPriceString.append(originalMinPriceValue);
            } else {
                originalPriceString.append(originalMinPrice);
            }
            holder.mOriginalPriceTextView.setTypeface(null, Typeface.NORMAL);
            holder.mOriginalPriceTextView.setTextColor(mActivity.get()
                    .getResources().getColor(R.color.pmp_original_text));
            holder.mOriginalPriceTextView.setText(originalPriceString);

您可以在上面的代码中看到我附加美元符号。

这是我的xml

<com.kohls.mcommerce.opal.framework.view.component.views.GothamBookTextView
    android:id="@+id/id_product_itemOriginalPriceTxt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/id_product_itemSaleClearancePriceText"
    android:layout_gravity="left"
    android:maxLines="2"
    android:singleLine="false"
    android:textColor="@color/pmp_original_text"
    android:textSize="@dimen/font_size_product_detail_grid_view" />

这是

public class GothamBookTextView extends TextView {
Typeface mGothamBoldTypeface;

public GothamBookTextView(Context context,
        AttributeSet attrs,
        int defStyle) {
    super(context, attrs, defStyle);
    init();
}

public GothamBookTextView(Context context,
        AttributeSet attrs) {
    super(context, attrs);
    init();
}

public GothamBookTextView(Context context) {
    super(context);
    init();
}

private void init() {
    if (!isInEditMode()) {
        mGothamBoldTypeface = FontUtils.loadTypeFace(getContext(), FontUtils.Gotham_Book);
        setTypeface(mGothamBoldTypeface);
    }
}
}

截图:

what the dollar sign looks like

0 个答案:

没有答案
相关问题