1

使用 textview 我使用此代码更改文本大小。现在我用 textswitcher 更改了 textview,我不能使用“setTextSize”。应该使用哪种方法?

mSwitcher = (TextSwitcher) findViewById(R.id.switcher);
      mSwitcher.setFactory(this);

      Animation in = AnimationUtils.loadAnimation(this,
              android.R.anim.fade_in);
      Animation out = AnimationUtils.loadAnimation(this,
              android.R.anim.fade_out);
      mSwitcher.setInAnimation(in);
      mSwitcher.setOutAnimation(out);


        seekBar1.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
                  public void onStopTrackingTouch(SeekBar seekBar) {
        [...]
    seek=10;
              seekBar1.setProgress(seek);
//        textView1.setTextSize(seek);


I've a public View makeView() {
        TextView t = new TextView(this);
        t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
        t.setTextSize(seek);
        return t;
    }
4

1 回答 1

1

您可以使用

 mSwitcher = (TextSwitcher) findViewById(R.id.switcher);
 mSwitcher.setFactory(this); 

 TextView t1 = (TextView) mSwitcher.getChildAt(0); 

 public View makeView() {
     TextView t = new TextView(this);
     t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
     t.setTextSize(36);

     return t;
  } 
于 2013-01-03T12:09:54.710 回答