how setup the font size of text in a Button


Last Updated: 2013-02-02 08:38:50
  1. lse123

    lse123 Well-Known Member

    how setup the font size of text in a
    HTML:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <Button xmlns:android="http://schemas.android.com/apk/res/android"
    3.   android:id="@+id/newGuessButton" android:layout_weight="1"
    4.   android:layout_width="wrap_content"
    5.   android:layout_height="wrap_content"></Button>

    Advertisement
  2. jonbonazza

    jonbonazza Well-Known Member

    add
    Code (Text):
    1.  
    2. android:fontSize="10sp"
    3.  
    to your button xml, where 10sp can be w/e size you want.
  3. lse123

    lse123 Well-Known Member

  4. lse123

    lse123 Well-Known Member

    what about setting font properties and particularly size of button font, from java?
  5. lse123

    lse123 Well-Known Member

    newGuessButton.setTextSize(10); used this success... what 10 is measured for in this case???
  6. jonbonazza

    jonbonazza Well-Known Member

  7. lse123

    lse123 Well-Known Member

    void setTextSize(float size)
    Set the default text size to the given value, interpreted as "scaled pixel" units.
    void setTextSize(int unit, float size)
    Set the default text size to a given unit and value.

    yes i saw but DEFAULT is sp units? if set a unit i supposed to use
    void setTextSize(COMPLEX_UNIT_PX, 10)
    void setTextSize(COMPLEX_UNIT_SP, 10)
  8. lse123

    lse123 Well-Known Member

    also what's the default size if the command missing in xml and also missing in java?

Share This Page