我想将动作添加到文本块,以便它从屏幕右侧进入。有没有办法做到这一点如何在android studio中为文本视图添加动画
1
A
回答
0
是的,你可以用动画以动画全景,特别是TranslateAnimation
从屏幕右侧输入:https://developer.android.com/guide/topics/graphics/view-animation.html
0
您可以创建一个transition
文件。例如:
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
android:transitionOrdering="together"
android:duration="250">
<slide android:slideEdge="right">
<targets>
<target android:targetId="@id/toolbar" />
</targets>
</slide>
</transitionSet>
然后在代码中你开始你的活动:
Intent intent = new Intent(this, YourActivityHere.class);
ActivityOptionsCompat activityOptions =
ActivityOptionsCompat.makeSceneTransitionAnimation(this,
new Pair<View, String>(viewHolder.mIconView, getString(R.string.detail_icon_transition_name)));
ActivityCompat.startActivity(this, intent, activityOptions.toBundle());
0
使用这个库,方便TextView的动画包括左到右 链接 - >Here
或以编程方式从X ---到------> X1的简单动画(您可以通过更改负值/正值来恢复),
创建anim文件夹res(新建>目录)> anim
添加资源XML
move_it.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromXDelta="-3%p"
android:toXDelta="30%p"
android:duration="1200" />
</set>
,并在你的代码
textView = (TextView) findViewById(R.id.text_one);
textView.startAnimation(AnimationUtils.loadAnimation(YourActivityName.this, R.anim.move_it));
0
TextSwitcher如何,每当文本发生变化,然后发生动画。
<TextSwitcher
android:id="@+id/txtSwitcher"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
然后在你的代码:
TextSwitcher switcher = (TextSwitcher)findViewById(txtSwitcher);
switcher.setFactory(new ViewFactory() {
@Override
public View makeView() {
TextView t = new TextView(ActivityClass.this);
//do other stuff the suit your needs
return t;
}
});
Animation in = AnimationUtils.loadAnimation(this,
android.R.anim.slide_in_left);
Animation out = AnimationUtils.loadAnimation(this,
android.R.anim.slide_out_right);
switcher.setInAnimation(in);
switcher.setOutAnimation(out);
如果你switcher.setText( “新文本”),则动画会发生。
相关问题
- 1. 如何在Recycler视图中为视图添加动画
- 2. Android Studio如何动画移动视图?
- 3. 如何在Android Studio中为背景添加动画效果?
- 4. 动画/转换文本/文本视图 - android studio
- 5. 如何在android中动态添加文本视图到列表视图?
- 6. 如何在Android Studio中为视频/ VideoURI添加水印/文字
- 7. 如何在视频中为图像添加动画
- 8. 添加动画子视图
- 9. 添加动画视图
- 10. Android:如何添加图像,然后在滚动视图中的文本下方?
- 11. 如何在android中为文本视图获取“幻灯片解锁”动画?
- 12. 在选项卡中动态添加文本视图(Android)
- 13. 添加逆向动画时,Android动画显示空白视图
- 14. Android将文本动态添加到文本视图片段(wrap_content)
- 15. 在Qt中为图像添加动画
- 16. 添加在WindowManager上的动画视图
- 17. 如何在android中为文本视图设置自动刷新?
- 18. 如何在回收站视图适配器中添加动态文本视图?
- 19. 如何将视图添加到Android中的滚动视图?
- 20. 如何在Android中的滚动视图中添加动态行视图?
- 21. 在android中动态添加视图
- 22. 添加了文本的Android滚动视图自动滚动
- 23. 如何为视图的点击框添加动画?
- 24. 如何在android中动态添加滚动视图
- 25. 在Android Studio中添加和删除动态列表中的文字视图?
- 26. 的Android添加文本视图
- 27. 如何将动画android文本视图缩放到右侧
- 28. 动态添加视频在动画中
- 29. 如何在Android中为TabActivity更改添加动画?
- 30. 通过Android中的java代码动态添加文本视图
它说 - 无法找到以下类com.hanks.htextview.Htextview –
@ K.A. Siddiqui你知道如何使用它吗? 1.在您的gradle中添加依赖项并同步它。2.然后您可以使用它们的自定义XML ..您可以提供您想要的动画类型!阅读**使用**部分,展示如何使用它,它的作用就像魅力,如果你需要一个正常的,你可以使用我的代码示例 –