Copper Street 1 -- TextSwitcher achieves text flop up and down effect,

Source: Internet
Author: User

Copper Street 1 -- TextSwitcher achieves text flop up and down effect,

TvNotice = (TextSwitcher) rootView. findViewById (R. id. TV _notice); tvNotice. setFactory (new ViewSwitcher. viewFactory () {// here is used to create an internal View. Here, TextView is created to display the text public View makeView () {TextView TV = new TextView (getContext ()); // set the text size TV. setTextSize (TypedValue. COMPLEX_UNIT_PX, getResources (). getDimension (R. dimen. group_notice_font_size); // sets the text color TV. setTextColor (getResources (). getColor (R. color. font_333333); return TV ;}});

Then you can use timer or Thread to control carousel. The code for controlling tvNotice in carousel is as follows:

// Set tvNotice. setInAnimation (AnimationUtils. loadAnimation (getContext (), R. anim. slide_in_bottom); // sets the cut-out animation tvNotice. setOutAnimation (AnimationUtils. loadAnimation (getContext (), R. anim. slide_out_up); // items is a string list, and index is the index tvNotice in the items to be displayed dynamically. setText (itmes. get (index ). getTitle ());

Slide_in_bottom.xml

<?xml version="1.0" encoding="utf-8"?>  <set xmlns:android="http://schemas.android.com/apk/res/android"      android:fillAfter="true"      android:shareInterpolator="false"    android:zAdjustment="top"      >      <translate          android:duration="1000"          android:fromYDelta="100%p"          android:toYDelta="0" />  </set> 

Slide_out_up.xml

<?xml version="1.0" encoding="utf-8"?>  <set xmlns:android="http://schemas.android.com/apk/res/android"      android:fillAfter="true"      android:shareInterpolator="false"    android:zAdjustment="top"      >      <translate          android:duration="1000"          android:fromYDelta="0"          android:toYDelta="-100%p" />  </set>  

  

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.