FLASH时,怎样设置汉字逐字出现的flash文字动画效果果

更多频道内容在这里查看
爱奇艺用户将能永久保存播放记录
过滤短视频
暂无长视频(电视剧、纪录片、动漫、综艺、电影)播放记录,
使用您的微博帐号登录,即刻尊享微博用户专属服务。
使用您的QQ帐号登录,即刻尊享QQ用户专属服务。
使用您的人人帐号登录,即刻尊享人人用户专属服务。
按住视频可进行拖动
把视频贴到Blog或BBS
当前浏览器仅支持手动复制代码
视频地址:
flash地址:
html代码:
通用代码:
通用代码可同时支持电脑和移动设备的分享播放
收藏成功,可进入查看所有收藏列表
方式1:用手机看
用爱奇艺APP或微信扫一扫,在手机上继续观看:
【大丰PPT】如何让古诗逐字逐句出现动画
方式2:一键下载至手机
限爱奇艺安卓6.0以上版本
使用微信扫一扫,扫描左侧二维码,下载爱奇艺移动APP
其他安装方式:手机浏览器输入短链接http://71.am/udn
下载安装包到本机:&&
设备搜寻中...
请确保您要连接的设备(仅限安卓)登录了同一爱奇艺账号 且安装并开启不低于V6.0以上版本的爱奇艺客户端
连接失败!
请确保您要连接的设备(仅限安卓)登录了同一爱奇艺账号 且安装并开启不低于V6.0以上版本的爱奇艺客户端
部安卓(Android)设备,请点击进行选择
请您在手机端下载爱奇艺移动APP(仅支持安卓客户端)
使用微信扫一扫,下载爱奇艺移动APP
其他安装方式:手机浏览器输入短链接http://71.am/udn
下载安装包到本机:&&
爱奇艺云推送
请您在手机端登录爱奇艺移动APP(仅支持安卓客户端)
使用微信扫一扫,下载爱奇艺移动APP
180秒后更新
打开爱奇艺移动APP,点击“我的-扫一扫”,扫描左侧二维码进行登录
没有安装爱奇艺视频最新客户端?
爸爸去哪儿2游戏 立即参与
【大丰PPT】如何让古诗逐字逐句出现动画
播放量数据:
1,429人已订阅
你可能还想订阅他们:
{{#needAdBadge}} 广告{{/needAdBadge}}
&正在加载...
您使用浏览器不支持直接复制的功能,建议您使用Ctrl+C或右键全选进行地址复制
安装爱奇艺视频客户端,
马上开始为您下载本片
5秒后自动消失
&li data-elem="tabtitle" data-seq="{{seq}}"& &a href="javascript:void(0);"& &span>{{start}}-{{end}}&/span& &/a& &/li&
&li data-downloadSelect-elem="item" data-downloadSelect-selected="false" data-downloadSelect-tvid="{{tvid}}"& &a href="javascript:void(0);"&{{pd}}&/a&
选择您要下载的《
色情低俗内容
血腥暴力内容
广告或欺诈内容
侵犯了我的权力
还可以输入
您使用浏览器不支持直接复制的功能,建议您使用Ctrl+C或右键全选进行地址复制利用Android中的TextView实现逐字显示动画
投稿:daisy
字体:[ ] 类型:转载 时间:
在安卓程序启动的时候,想逐字显示一段话,每个字都有一个从透明到不透明的渐变动画。那如何显示这个效果,下面一起来看看。
Android的TextView只能设置整个TextView的动画,而不能设置每个文字的动画。即使是使用TextSwitcher,也很难实现我想要的效果。
所以选择自定义一个。大体思路是:继承ViewGroup,设置Text的时候,每个文字为一个TextView,每隔一个固定时间,启动每个TextView的动画。
&定义一个CTextView,继承ViewGroup:
实现主要代码:
public class CTextView extends ViewGroup {
向外提供一个方法setText(String text, final Animation animation, int duration),text为要显示的字符串,animation为每个字符的动画,duration为字符动画的播放间隔。
该方法实现如下:
public void setText(String text, final Animation animation, int duration) {
int time = 0;
if(text != null && !text.isEmpty()) {
char[] characters = text.toCharArray();
for(char c : characters) {
final TextView t = new TextView(context);
//遍历传入的字符串的每个字符,生成一个TextView,并设置它的动画
t.setText(String.valueOf(c));
t.setTextSize(28);
Handler h = new Handler();
//每隔duration时间,播放下一个TextView的动画
h.postDelayed(new Runnable() {
public void run() {
addView(t);
t.setAnimation(animation);
CTextView完整实现如下:
import android.content.C
import android.os.H
import android.util.AttributeS
import android.view.V
import android.view.ViewG
import android.view.animation.A
import android.widget.TextV
* Created by cchen on .
public class CTextView extends ViewGroup {
public CTextView(Context context) {
super(context);
this.context =
public CTextView(Context context, AttributeSet attrs) {
super(context, attrs);
this.context =
public CTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.context =
public void setText(String text, final Animation animation, int duration) {
int time = 0;
if(text != null && !text.isEmpty()) {
char[] characters = text.toCharArray();
for(char c : characters) {
final TextView t = new TextView(context);
//遍历传入的字符串的每个字符,生成一个TextView,并设置它的动画
t.setText(String.valueOf(c));
t.setTextSize(28);
Handler h = new Handler();
//每隔duration时间,播放下一个TextView的动画
h.postDelayed(new Runnable() {
public void run() {
addView(t);
t.setAnimation(animation);
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int measureWidth = measureWidth(widthMeasureSpec);
int measureHeight = measureHeight(heightMeasureSpec);
// 计算自定义的ViewGroup中所有子控件的大小
measureChildren(widthMeasureSpec, heightMeasureSpec);
// 设置自定义的控件MyViewGroup的大小
setMeasuredDimension(measureWidth, measureHeight);
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int childLeft = 0;
// 遍历所有子视图
int childCount = getChildCount();
for (int i = 0; i & childC i++) {
View childView = getChildAt(i);
// 获取在onMeasure中计算的视图尺寸
int measureHeight = childView.getMeasuredHeight();
int measuredWidth = childView.getMeasuredWidth();
//将他们横向排列
childView.layout(childLeft, 0, childLeft + measuredWidth, measureHeight);
childLeft += measuredW
private int measureWidth(int pWidthMeasureSpec) {
int result = 0;
int widthMode = MeasureSpec.getMode(pWidthMeasureSpec);// 得到模式
int widthSize = MeasureSpec.getSize(pWidthMeasureSpec);// 得到尺寸
switch (widthMode) {
* mode共有三种情况,取值分别为MeasureSpec.UNSPECIFIED, MeasureSpec.EXACTLY,
* MeasureSpec.AT_MOST。
* MeasureSpec.EXACTLY是精确尺寸,
* 当我们将控件的layout_width或layout_height指定为具体数值时如andorid
* :layout_width="50dip",或者为FILL_PARENT是,都是控件大小已经确定的情况,都是精确尺寸。
* MeasureSpec.AT_MOST是最大尺寸,
* 当控件的layout_width或layout_height指定为WRAP_CONTENT时
* ,控件大小一般随着控件的子空间或内容进行变化,此时控件尺寸只要不超过父控件允许的最大尺寸即可
* 。因此,此时的mode是AT_MOST,size给出了父控件允许的最大尺寸。
* MeasureSpec.UNSPECIFIED是未指定尺寸,这种情况不多,一般都是父控件是AdapterView,
* 通过measure方法传入的模式。
case MeasureSpec.AT_MOST:
case MeasureSpec.EXACTLY:
result = widthS
private int measureHeight(int pHeightMeasureSpec) {
int result = 0;
int heightMode = MeasureSpec.getMode(pHeightMeasureSpec);
int heightSize = MeasureSpec.getSize(pHeightMeasureSpec);
switch (heightMode) {
case MeasureSpec.AT_MOST:
case MeasureSpec.EXACTLY:
result = heightS
然后在布局文件中使用该自定义组件:
&LinearLayout xmlns:android="/apk/res/android"
xmlns:tools="/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".NetworkTestActivity"&
&com.network.cchen.network.CTextView
android:id="@+id/cTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"&
&/com.network.cchen.network.CTextView&
&/LinearLayout&
在Activity中,调用CTextView的setText方法,传入相关参数即可:
import android.app.A
import android.os.B
import android.view.animation.AnimationU
public class TestActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_network_test);
CTextView cTextView = (CTextView) findViewById(R.id.cTextView);
cTextView.setText("Hello world", AnimationUtils.loadAnimation(this, R.anim.myanim), 300);
其中的第二个参数为动画,我想要的效果是从透明到不透明,myanim.xml:
&?xml version="1.0" encoding="utf-8"?&
&set xmlns:android="/apk/res/android"&
android:duration="1000"
android:fromAlpha="0.0"
android:toAlpha="1.0" /&
如果想实现文字逐个从右侧飞入:
&?xml version="1.0" encoding="utf-8"?&
&set xmlns:android="/apk/res/android"&
&translate
android:duration="1000"
android:fillAfter="true"
android:fromXDelta="50%p"
android:interpolator="@android:anim/anticipate_interpolator"
android:toXDelta="0" /&
以上就是利用Android中的TextView实现逐字动画的全部内容,实现后效果还是很赞的,感兴趣的小伙伴们自己动手实践起来吧。如果有疑问可以留言讨论。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具

我要回帖

更多关于 flash文字动画效果 的文章

 

随机推荐