我希望能夠進行文字動畫並更改TextView中文字的大小。我讀過在android中有屬性動畫,但如果有人知道一個簡單的代碼可以爲我做這個或一個例子,我會深深地感激它。提前感謝你!TextView的文字大小動畫
6
A
回答
15
scale.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="2.0"
android:toYScale="2.0"
android:duration="3000"></scale>
</set>
函數到活動:
private void RunAnimation()
{
Animation a = AnimationUtils.loadAnimation(this, R.anim.scale);
a.reset();
TextView tv = (TextView) findViewById(R.id.firstTextView);
tv.clearAnimation();
tv.startAnimation(a);
}
提取,如果您正在使用按鈕事件,顯示動畫從here
3
5
Animation animation=new TranslateAnimation(0,480,0,0);
animation.setDuration(5000);
animation.setRepeatMode(Animation.RESTART);
animation.setRepeatCount(Animation.INFINITE);
text.startAnimation(animation);
// applying animation to textview object..
修改然後把onClick()中的代碼否則使用覆蓋方法onWindowFocusChanged (布爾hasFocus)啓動動畫
1
在Android
final float startSize = o; // Size in pixels
final float endSize = 30;
final int animationDuration = 1000; // Animation duration in ms
ValueAnimator animator = ValueAnimator.ofFloat(startSize, endSize);
animator.setDuration(animationDuration);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float animatedValue = (float) valueAnimator.getAnimatedValue();
tv.setTextSize(animatedValue);
}
});
animator.start();
使用ValueAnimator類是指該鏈接ValueAnimator
另一種解決方案是,在TextView的或其父佈局應用規模的動畫
ScaleAnimation scaleAnimation = new ScaleAnimation(0.7f, 1.1f, 0.7f, 1.1f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(600);
viewZoom.startAnimation(scaleAnimation);
+0
已複製的代碼來自[此回答](http://stackoverflow.com/a/30324368/2025923) – Tushar
+0
即使在OnePlus3T上工作也不順利( –
相關問題
- 1. 將TextView文字大小綁定到另一個TextView大小
- 2. 動畫字體大小
- 3. TextView中文本的自動大小寫
- 4. TextView中的字體大小
- 5. TextView字體大小自動縮放
- 6. 動態Android TextView大小
- 7. 如何更改場景過渡動畫中的TextView大小?
- 8. TextView的動畫
- 9. 如何動畫CCLabelTTF的字體大小?
- 10. TextView文本大小方法
- 11. TextView:縮小比例並按順序動畫放大
- 12. Android textView錯誤? sp中的最大文字大小
- 13. 動畫的圖像大小!
- 14. 如何動畫字符大小?
- 15. CATextLayer字體大小動畫速度
- 16. 動畫菜單和Cufon字體大小
- 17. TextView的自動調整大小
- 18. 動態增加textview的大小
- 19. 更改AppWidget上TextView的字體大小
- 20. 更改字體/文字大小時的Textview對齊問題
- 21. 如何使我的TextView字體大小動態取決於父視圖大小
- 22. Android的大小調整的TextView文字大小,以便它是單線
- 23. 畫布大小 - 文字渲染
- 24. 文字在動畫轉換上的大小調整
- 25. 在textview中計數動畫的數字
- 26. 在TextView中動畫文字的垂直滾動
- 27. 帶有不同文本大小的TextView
- 28. 將Android WebView文本大小匹配到TextView文本大小
- 29. Android的,問題在TextView的調整我的文字的大小
- 30. 動畫UITableView調整大小
相關信息[android textview的文本大小而不是整個TextView的動畫](// stackoverflow.com/a/30324368) – Tushar