创建文本变化的动画效果

package com.example.androidtest;import android.os.Bundle;
import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextSwitcher;
import android.widget.TextView;
import android.widget.ViewSwitcher;public class MainActivity extends Activity implements ViewSwitcher.ViewFactory, View.OnClickListener{private TextSwitcher mSwitcher;private int mCounter = 0;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main); mSwitcher = (TextSwitcher)findViewById(R.id.switcher);mSwitcher.setFactory(this);Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);Animation out = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);mSwitcher.setInAnimation(in);mSwitcher.setOutAnimation(out);Button nextButton = (Button)findViewById(R.id.next);nextButton.setOnClickListener(this);updateCounter();}  private void updateCounter(){mSwitcher.setText(String.valueOf(mCounter));}public View makeView(){TextView t = new TextView(this);t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);t.setTextSize(36);return t;}public void onClick(View v){mCounter++;updateCounter();}
}

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><Button android:id="@+id/next"android:layout_width="wrap_content"android:layout_height="wrap_content" android:text="@string/text_switcher_1_next_text" /><TextSwitcher android:id="@+id/switcher"android:layout_width="match_parent"android:layout_height="wrap_content" /></LinearLayout>

TextSwitcher的使用(一)相关推荐

  1. TextSwitcher实现文本自动垂直滚动

    本文转载自[http://blog.csdn.net/u014369799/article/details/50337229] 实现功能:用TextSwitcher实现文本自动垂直滚动,类似淘宝首页广 ...

  2. Android 中文 API —— TextSwitcher

    2019独角兽企业重金招聘Python工程师标准>>> 声明 欢迎转载,但请保留文章原始出处:) madgoat:http://madgoat.cn/ 博客园:http://www. ...

  3. 控件(View)之TextSwitcher, Gallery, ImageSwitcher, GridView, ListView, ExpandableList【转】

    在 Android 中使用各种控件(View) TextSwitcher - 文字转换器控件(改变文字时增加一些动画效果) Gallery - 缩略图浏览器控件 ImageSwitcher - 图片转 ...

  4. textswitcher_Android TextSwitcher和ImageSwitcher示例教程

    textswitcher Android TextSwitcher and ImageSwitcher are classes used to add animations to texts and ...

  5. 通过TextSwitcher实现广告栏内容动画切换

    textswitcher 1,布局中使用 <TextSwitcherandroid:id="@+id/switcher"android:layout_width=" ...

  6. 第5组UI 让你的界面酷炫到底-ViewAniMator之ViewSwitcher、ImageSwitcher(图像切换器)、TextSwitcher(文本切换器)、ViewFlipper

    ViewAniMator是一个基类,它继承了FrameLayout,因此它表现了FrameLayout的一些特征,可以将多个View组件"叠"在一起.额外的功能是:在View切换时 ...

  7. Android文字广告(Textview上下滚动),使用TextSwitcher控件的完整实现

    实现步骤: a.xml布局 <TextSwitcherandroid:id="@+id/textSwitcher"android:layout_width="mat ...

  8. Android文字广告(Textview上下滚动),使用TextSwitcher控件实现

    经常可以在app上面看到许多的上下滚动textview,是可以直接使用TextSwitcher直接实现的. 开始还写了个自定义view来实现,然后发现官方原来有(:з」∠). 控件还有ImageSwi ...

  9. 安卓控件TextSwitcher的使用(实现Textview的上下滚动)

    经常可以在app上面看到许多的上下滚动textview,是可以直接使用TextSwitcher直接实现的. 开始还写了个自定义view来实现,然后发现官方原来有(:з」∠). 控件还有ImageSwi ...

最新文章

  1. LeetCode刷题记录12——232. Implement Queue using Stacks(easy)
  2. 王爽汇编第二册:将每个单词的前四位改为大写字母
  3. 全局处理ajax请求时session超时
  4. port wifi to ICS(4.0.3)
  5. Mastering Unity 2D Game Development
  6. linux怎么同时运行多个程序吗,Linux配置多个tomcat同时运行
  7. Flutter进阶—质感设计之弹出菜单
  8. 实用防火墙(Iptables)脚本分析
  9. HDU 2063 过山车
  10. Java 代码调用 Maven 命令
  11. Docker容器-------dockerfile概念简介
  12. springboot 整合 邮件发送
  13. 精读《图解密码技术》--第一章 环游密码世界
  14. 湖大计算机学院博士后李晓灿,李蕊-湖大信息科学与工程学院
  15. SQL Server Management Studio (SSMS)
  16. NAT模式/路由模式/全路由模式
  17. vue 路由懒加载 报错 Loading chunk * failed 组件加载不出来
  18. python区间分布统计_常见概率统计分布及Python实现
  19. 全球化手册|日本篇笔记
  20. 信息管理,数据库相关

热门文章

  1. python量化投资必背代码-重磅!我把自己耗费两年用Python写的量化投资代码开源了!...
  2. 开课吧python小课值得么-材料学硕博士建议掌握的高效论文工具
  3. python简单代码表白-如何正确使用Python进行表白
  4. python怎么知道用哪个库使用-dir、help 查看python 库 对应的方法 和使用
  5. python怎么把数据写入txt-如何将python中文件写入TXT
  6. python利器怎么编程-python等自动化脚本编程利器 Script.NET
  7. python3各个版本是通用的吗-python3各版本
  8. python映射类型-python2.x学习笔记(8)-映射和集合类型
  9. python画图程序-编程入门06:Python海龟绘图
  10. python常用命令汇总-酷帅吊炸天的 Pandas 常用操作命令汇总