Widespread Augmented Reality

Widespread Augmented Reality
Click on the image to get the Android Augmented Reality Heads up Display

Saturday, December 14, 2013

Text Animation on Android App for Augmented Reality

Two flavors of Widespread Augmented Reality (W.A.R.) or Warmixare
  • Android Jelly Bean+
  • Android Ice Cream Sandwich Tablets
  • Here is the XML layout.

    Here is the slide_in_left layout in the the /res/anim folder

    Here is the Java code


    public class SplashScreen extends Activity {
    private TextSwitcher ts1, ts2, ts3;
    final String wordsToShow[]={"idespread ","ugmented ","eality "};
    int wordCount=wordsToShow.length;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashlayout);
    Animation slide =
    AnimationUtils.loadAnimation(getApplicationContext(),android.R.anim.slide_in_left);
    Animation fade =
    AnimationUtils.loadAnimation(getApplicationContext(),android.R.anim.fade_in);
    slide.setDuration(2000);
    fade.setDuration(3000);
    final TextView w = (TextView) findViewById(R.id.w1);
    final TextView a = (TextView) findViewById(R.id.a1);
    final TextView r = (TextView) findViewById(R.id.r1);
    w.setAnimation(fade); a.setAnimation(fade); r.setAnimation(fade);
    ts1 = (TextSwitcher) findViewById(R.id.widespread2);
    ts2 = (TextSwitcher) findViewById(R.id.augmented2);
    ts3 = (TextSwitcher) findViewById(R.id.reality2);
    ts1.setFactory(new ViewFactory() {
    public View makeView() {
    TextView myText = new TextView(SplashScreen.this);
    myText.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    myText.setTextSize(28);
    myText.setTextColor(Color.WHITE);
    return myText;
    }
    });
    ts2.setFactory(new ViewFactory() {
    public View makeView() {
    TextView myText2 = new TextView(SplashScreen.this);
    myText2.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    myText2.setTextSize(28);
    myText2.setTextColor(Color.WHITE);
    return myText2;
    }
    });
    ts3.setFactory(new ViewFactory() {
    public View makeView() {
    TextView myText3 = new TextView(SplashScreen.this);
    myText3.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    myText3.setTextSize(28);
    myText3.setTextColor(Color.WHITE);
    return myText3;
    }
    });
    ts1.setText(wordsToShow[0]);
    ts1.startAnimation(slide);
    ts2.setText(wordsToShow[1]);
    ts2.startAnimation(slide);
    ts3.setText(wordsToShow[2]);
    ts3.startAnimation(slide);

    No comments:

    Post a Comment