Detailed explanation of Android textswitcher, text switcher and viewflipper

This article shares the use of Android textswitcher text switcher for your reference. The specific contents are as follows

@H_ 403_ 4@

1.TextSwitcher

use:

The application is divided into three steps:

1. Get the textswitcher instance object textswitcher switcher = (textswitcher) findviewbyid (r.id.textswitcher); 2. Specify the viewswitcher.viewfactory factory for the switcher, which will generate the view switcher.setfactory (this) required for conversion; 3. Set the displayed content for the switcher. When this method is executed, it will switch to the next view switcher.settext (string. Valueof (New random(). Nextint()));

2.ViewFlipper

realization:

① Create a main layout file containing the viewflipper control (from the source code, the viewflipper control is an integrated FrameLayout and is equivalent to a frame layout, but contains some special properties)

② Create a child view of viewflipper, that is, two linearlayouts (including two textviews)

③ Create the entry and exit animation anim of sub view in viewflipper_ In and anim_ Out two animation files

④ Add two child views to the viewflipper in the activity, and transfer the addview method of the viewflipper

Specific code:

① Create main layout file

activity_ main.xml

② Create a child view of viewflipper. Here are two. I only give one, and the other is the same

one_ ads.xml

③ Create the entry and exit animation anim of sub view in viewflipper_ In and anim_ Out two animation files, and only anim is given here_ In code, anim_ The out code is similar

anim_ in.xml

④ Add two child views to the viewflipper in the activity, and transfer the addview method of the viewflipper

  MainActivity.java

OK, let's see our effect

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>