how setup the font size of text in a Button


Last Updated:

  1. lse123

    lse123 Well-Known Member This Topic's Starter

    Joined:
    Nov 19, 2010
    Messages:
    72
    Likes Received:
    0
    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

    Joined:
    Jul 13, 2010
    Messages:
    1,934
    Likes Received:
    458
    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 This Topic's Starter

    Joined:
    Nov 19, 2010
    Messages:
    72
    Likes Received:
    0
  4. lse123

    lse123 Well-Known Member This Topic's Starter

    Joined:
    Nov 19, 2010
    Messages:
    72
    Likes Received:
    0
    what about setting font properties and particularly size of button font, from java?
     
  5. lse123

    lse123 Well-Known Member This Topic's Starter

    Joined:
    Nov 19, 2010
    Messages:
    72
    Likes Received:
    0
    newGuessButton.setTextSize(10); used this success... what 10 is measured for in this case???
     
  6. jonbonazza

    jonbonazza Well-Known Member

    Joined:
    Jul 13, 2010
    Messages:
    1,934
    Likes Received:
    458
  7. lse123

    lse123 Well-Known Member This Topic's Starter

    Joined:
    Nov 19, 2010
    Messages:
    72
    Likes Received:
    0
    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 This Topic's Starter

    Joined:
    Nov 19, 2010
    Messages:
    72
    Likes Received:
    0
    also what's the default size if the command missing in xml and also missing in java?
     

Share This Page

Loading...