1

I want to support font resizing with an entry in Preferences (where the user picks among given font size options) or by using a gesture (flinging up/down) as used in popular e-book reader applications such as Aldiko. Flinging up and down along right side of the screen triggered brightness change in Aldiko.

How can I implement this type of dynamic property change? Are there any implementation differences for this in 1.6 and 2.0+ ? Do I have to have different themes pre-configured with different font sizes?

faraday
  • 324
  • 2
  • 7
  • 14

2 Answers2

8

Actually, you do it like that:

TextView tv=new TextView(this);

    //either:
    tv.setTextAppearance(this, R.style.textStyle1); //some style you have set up


    ///or: 
    tv.setTextSize(16);
    tv.setTextColor(R.color.myred); //some color you set up

so not a static call to TextView you need an isntance of textview.

vallllll
  • 2,731
  • 6
  • 43
  • 77
  • Okay, that one is trivial of course. However no such methods are available in Android 1.6. How can I achieve this in 1.6 ? – faraday Jul 20 '11 at 12:30
  • it works for 1.6 too http://developer.android.com/reference/android/widget/TextView.html you can set filter by api level – vallllll Jul 20 '11 at 12:38
3

Try this:

tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
mav_baumer15
  • 183
  • 2
  • 5