标签:android style blog io color os 使用 sp div
1. 应用场景:
1 public class MainActivity extends Activity { 2 private static final String[] TEXTS = { "First", "Second", "Third" }; 3 private int mTextsPosition = 0; 4 private TextSwitcher mTextSwitcher; 5 @Override 6 public void onCreate(Bundle savedInstanceState) { 7 super.onCreate(savedInstanceState); 8 setContentView(R.layout.main); 9 mTextSwitcher = (TextSwitcher) findViewById(R.id.your_textview); 10 mTextSwitcher.setFactory(new ViewFactory() { 11 @Override 12 public View makeView() { 13 System.out.println("makeView"); 14 TextView t = new TextView(MainActivity.this); 15 t.setGravity(Gravity.CENTER); 16 return t; 17 } 18 }); 19 mTextSwitcher.setInAnimation(this, android.R.anim.fade_in); 20 mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out); 21 onSwitchText(null); 22 } 23 public void onSwitchText(View v) { 24 mTextSwitcher.setText(TEXTS[mTextsPosition]); 25 setNextPosition(); 26 } 27 private void setNextPosition() { 28 mTextsPosition = (mTextsPosition + 1) % TEXTS.length; 29 } 30 }
Hackfive 使用TextSwitcher和ImageSwitcher实现平滑过渡
标签:android style blog io color os 使用 sp div
原文地址:http://www.cnblogs.com/liangstudyhome/p/4057272.html