2

How do I change the font ans font size on chronometer. When I align the chronometer with a textview it shows different size and settings. I also tried assigning font settings from textview.

chronometer.setTypeface(txtView.getTypeface());
chronometer.setTextSize(TypedValue.COMPLEX_UNIT_SP,txtView.getTextSize());
pats
  • 1,273
  • 2
  • 20
  • 43

1 Answers1

4

You can change the font style and font size on chronometer using following

XML

android:typeface="serif"
android:textSize="120dp"

in xml you can set default fonts of android.

JAVA

        Typeface font = Typeface.createFromAsset(getAssets(), "fonts/opensanslight.ttf");

        focus = (Chronometer) findViewById(R.id.chronometer1);
        focus.setTypeface(font, Typeface.NORMAL);
        focus.setTextSize(120);

where focus is chronometer.

for custom fonts

put your .ttf files in assets folder.

in android studio you have to create assets folder under src/main/assets/

  • 1
    Thanks for your response, but is it possible to assign font settings from a textview in the same layout pragmatically ? I dont want to add any ttf files as long as all controls use similar font settings. – pats Sep 25 '15 at 05:15
  • Yes it is possible first set typeface from xml or programatically.then **tv2.setTypeface(tv1.getTypeface());** of set a common typeface and use it in all program. – Tyler Durden Sep 25 '15 at 05:33