Lor*_*rof 35 animation android textview
我目前使用一个主要的解决方法,并在每次更改TextView上的文本时切换两个活动.我正在使用此代码:
Weeklytext.this.overridePendingTransition(
R.anim.slide_in_left,
R.anim.slide_out_right
);
Run Code Online (Sandbox Code Playgroud)
是否可以在一个活动中执行此操作?有两个活动具有完全相同的内容只是为了让我可以使用动画,这有点烦人;)
谢谢!请问你是否理解我的问题!
ant*_*nyt 67
在TextView中更改文本时,可以使用TextSwitcher来设置动画.
TextSwitcher只是一种特殊的ViewSwitcher,因此,它允许您提供两个可在其间进行动画处理的视图.当你调用setText()时,它会更新下一个TextView的文本,然后将其中的一个动画进入屏幕,然后将当前的一个动画.然后将旧的TextView指定为"下一个"TextView,并重复该过程.
您可以指定使用浏览setFactory(...)或只需添加两个TextViews将其与addView(...) .
// get a TextSwitcher view; instantiate in code or resolve from a layout/XML
TextSwitcher textSwitcher = new TextSwitcher(context);
// specify the in/out animations you wish to use
textSwitcher.setInAnimation(context, R.anim.slide_in_left);
textSwitcher.setOutAnimation(context, R.anim.slide_out_right);
// provide two TextViews for the TextSwitcher to use
// you can apply styles to these Views before adding
textSwitcher.addView(new TextView(context));
textSwitcher.addView(new TextView(context));
// you are now ready to use the TextSwitcher
// it will animate between calls to setText
textSwitcher.setText("hello");
...
textSwitcher.setText("goodbye");
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
24023 次 |
最近记录: |