FileDocCategorySizeDatePackage
MarqueeActivity.javaAPI DocAndroid 5.1 API2626Thu Mar 12 22:22:44 GMT 2015com.android.test.hwui

MarqueeActivity

public class MarqueeActivity extends android.app.Activity

Fields Summary
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);

        final LinearLayout linearLayout = new LinearLayout(this);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        
        final TextView text1 = new TextView(this);
        text1.setText("This is a marquee inside a TextView");
        text1.setSingleLine(true);
        text1.setHorizontalFadingEdgeEnabled(true);
        text1.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        linearLayout.addView(text1, new LinearLayout.LayoutParams(
                100, LinearLayout.LayoutParams.WRAP_CONTENT));

        final TextView text2 = new TextView(this);
        text2.setText("This is a marquee inside a TextView");
        text2.setSingleLine(true);
        text2.setHorizontalFadingEdgeEnabled(true);
        text2.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                100, LinearLayout.LayoutParams.WRAP_CONTENT);
        linearLayout.addView(text2, params);

        setContentView(linearLayout);
        
        getWindow().getDecorView().postDelayed(new Runnable() {
            @Override
            public void run() {
                text2.setVisibility(View.INVISIBLE);
                Animation animation = AnimationUtils.loadAnimation(text2.getContext(),
                        R.anim.slide_off_left);
                animation.setFillEnabled(true);
                animation.setFillAfter(true);
                text2.startAnimation(animation);
            }
        }, 1000);