Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with fonts in android 4.4

first screensecond screen

Today i've updated my android sdk to 19 api, and while testing my app I have encountered some bugs in 19 api: drop some fonts in text view, or have problems with it's size.

first screen, code of one view:

tvBalance = new TextView(getContext());
    rlParams = new LayoutParams(frame.width, (int) (frame.heigth * zoneExtetn));
    rlParams.setMargins(frame.left, (int) (frame.top - frame.heigth * (zoneUp-0.1f)), 0, 0);
    tvBalance.setLayoutParams(rlParams);
    tvBalance.setGravity(Gravity.CENTER);
    tvBalance.setPadding(0, 0, 0, 0);
    tvBalance.setTextColor(0xffffd008);
    tvBalance.setTextSize(PokerTextSize.scaleFont(getContext(), 28));
    tvBalance.setText("$ 0 000 000 000");
    tvBalance.setTypeface(TypefaceBase.getCalibri((Activity) getContext()));
    rlMoney.addView(tvBalance);

and second screen code:

TextView tvText = new TextView(llContent.getContext());
            llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            llParams.setMargins(0, 0, 0, marg*2);
            tvText.setLayoutParams(llParams);
            tvText.setTextSize(fonts[0]);
            tvText.setTextColor(articleColor);
            tvText.setText(Html.fromHtml(articleItem.getString()));
            tvText.setTypeface(TypefaceBase.getCalibri((Activity) this.getContext()));

            llContent.addView(tvText);

Anybody have these problems in android 4.4 kit-kat?

like image 282
Anton Avatar asked Nov 01 '13 13:11

Anton


1 Answers

I'm having a similar issue, and found this thread. See if that helps.

Custom ttf fonts are not showing properly in TextView on Android 4.4 KitKat

Edit:

I was having the same issue while using calibri.ttf. I switched over to lato.ttf (available on google.com/fonts), and they work fine/look extremely similar.

like image 72
Submersed Avatar answered Sep 26 '22 05:09

Submersed