Monday 15 September 2014

Animate Text Using TextSwitcher In Android -


I'm new to Android and learn to work with TextSwitcher. I want to know that a text can be animated using TextSwitcher.

I have texttext and a button layout when I click on the button, TextSwitcher should change the text.

I read about this here ....

But I can not get this work done.

Text, such that when I click on the button TextSwitcher Text Switch

The text screen can be used Tekstsvitr to animate on screen View blog for detail and blog to all content

We have to set the animation in and out.

  1. In animation: which comes with text screen
  2. Animation out: .. Which goes beyond the text screen with

    The expansion of appropriate comments

      main activity of the public square with the full address (Private Patvivir mSwitcher button Bitian Next { "show string of // array TextSwitcher string textToShow [] = main Title", "Your message", "" new Technology, "new article", "business News", "what is New "}; int message coat = texttosh.lamp; // current index of text Of keeping current intIndex = -1 for: @ Override protected void saved create (bundled Instansstet) {Suprknkret (saved Instensstet); SetContentView (Rklayoutkexamplel_layout) Get //; reference Bitianaksaks = (Button ) searches Vivibiaiaidi (Araidikbtnniptest); MSwitcher = (TextSwitcher) Find ViewById (R.id.textSwitcher); // TextSwitcher when mSwitcher.setFactory asked TextView object will cause the ViewFactory set (new ViewFactory () {public view MakeView ( ) {// TODO Automatic Created Method Stub // E can create textView and set properties like color, size, gravity etc. TextView myText = new TextView (MainActivity.this); MyText.setGravity (Gravity.TOP | Gravity.CENTER_HORIZONTAL); MyText.setTextSize (36); MyText.setTextColor (Color.BLUE); Returned myText;}}); // Announce animation inside and out and start animation in them animations = animation highs Load animation (this, Android.R.Enim.Slide_andLove); Animation Out = AnimationUtility Load animation (this, Android .Renim Solid_out_right); // Animation type text script mSwitcher.setInAnimation (in); MSwitcher.setOutAnimation (outside); // The next button for ClickListener will switch between TextSwitcher / texts when clicked on the button // Current text will go out and specify the next text animation btnNext.setOnClickListener (New View.OnClickListener) {public with Zero onClick (with view Will come in v) {// TODO auto-created method stub currentIndex ++; index reaches the maximum // if it resets (currentIndex == messageCount) currentIndex = 0; mSwitcher.setText (textToShow [currentIndex ]);}}); }}    

No comments:

Post a Comment