2013-01-03 36 views
1

使用文本視圖我使用此代碼更改文本大小。現在我用textswitcher更改textview,並且不能使用「setTextSize」。應該使用哪種方法?seekBar和文本切換器

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; 
    } 

回答

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; 
    } 
+0

謝謝!作品! :-)一個問題:現在我有一個正確的文本,下一個文本是不可見的,另一個文本正確,下一個文本不可見。我更新了我的代碼。 –