TextSwitcher的使用(一)
创建文本变化的动画效果
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的使用(一)相关推荐
- TextSwitcher实现文本自动垂直滚动
本文转载自[http://blog.csdn.net/u014369799/article/details/50337229] 实现功能:用TextSwitcher实现文本自动垂直滚动,类似淘宝首页广 ...
- Android 中文 API —— TextSwitcher
2019独角兽企业重金招聘Python工程师标准>>> 声明 欢迎转载,但请保留文章原始出处:) madgoat:http://madgoat.cn/ 博客园:http://www. ...
- 控件(View)之TextSwitcher, Gallery, ImageSwitcher, GridView, ListView, ExpandableList【转】
在 Android 中使用各种控件(View) TextSwitcher - 文字转换器控件(改变文字时增加一些动画效果) Gallery - 缩略图浏览器控件 ImageSwitcher - 图片转 ...
- textswitcher_Android TextSwitcher和ImageSwitcher示例教程
textswitcher Android TextSwitcher and ImageSwitcher are classes used to add animations to texts and ...
- 通过TextSwitcher实现广告栏内容动画切换
textswitcher 1,布局中使用 <TextSwitcherandroid:id="@+id/switcher"android:layout_width=" ...
- 第5组UI 让你的界面酷炫到底-ViewAniMator之ViewSwitcher、ImageSwitcher(图像切换器)、TextSwitcher(文本切换器)、ViewFlipper
ViewAniMator是一个基类,它继承了FrameLayout,因此它表现了FrameLayout的一些特征,可以将多个View组件"叠"在一起.额外的功能是:在View切换时 ...
- Android文字广告(Textview上下滚动),使用TextSwitcher控件的完整实现
实现步骤: a.xml布局 <TextSwitcherandroid:id="@+id/textSwitcher"android:layout_width="mat ...
- Android文字广告(Textview上下滚动),使用TextSwitcher控件实现
经常可以在app上面看到许多的上下滚动textview,是可以直接使用TextSwitcher直接实现的. 开始还写了个自定义view来实现,然后发现官方原来有(:з」∠). 控件还有ImageSwi ...
- 安卓控件TextSwitcher的使用(实现Textview的上下滚动)
经常可以在app上面看到许多的上下滚动textview,是可以直接使用TextSwitcher直接实现的. 开始还写了个自定义view来实现,然后发现官方原来有(:з」∠). 控件还有ImageSwi ...
最新文章
- LeetCode刷题记录12——232. Implement Queue using Stacks(easy)
- 王爽汇编第二册:将每个单词的前四位改为大写字母
- 全局处理ajax请求时session超时
- port wifi to ICS(4.0.3)
- Mastering Unity 2D Game Development
- linux怎么同时运行多个程序吗,Linux配置多个tomcat同时运行
- Flutter进阶—质感设计之弹出菜单
- 实用防火墙(Iptables)脚本分析
- HDU 2063 过山车
- Java 代码调用 Maven 命令
- Docker容器-------dockerfile概念简介
- springboot 整合 邮件发送
- 精读《图解密码技术》--第一章 环游密码世界
- 湖大计算机学院博士后李晓灿,李蕊-湖大信息科学与工程学院
- SQL Server Management Studio (SSMS)
- NAT模式/路由模式/全路由模式
- vue 路由懒加载 报错 Loading chunk * failed 组件加载不出来
- python区间分布统计_常见概率统计分布及Python实现
- 全球化手册|日本篇笔记
- 信息管理,数据库相关
热门文章
- python量化投资必背代码-重磅!我把自己耗费两年用Python写的量化投资代码开源了!...
- 开课吧python小课值得么-材料学硕博士建议掌握的高效论文工具
- python简单代码表白-如何正确使用Python进行表白
- python怎么知道用哪个库使用-dir、help 查看python 库 对应的方法 和使用
- python怎么把数据写入txt-如何将python中文件写入TXT
- python利器怎么编程-python等自动化脚本编程利器 Script.NET
- python3各个版本是通用的吗-python3各版本
- python映射类型-python2.x学习笔记(8)-映射和集合类型
- python画图程序-编程入门06:Python海龟绘图
- python常用命令汇总-酷帅吊炸天的 Pandas 常用操作命令汇总