rei*_*eki 3 xml android android-animation android-edittext
我想创建一个在其父级左侧对齐的edittext,当用户单击它时,edittext的width将增加到右侧.这是我使用的代码.但是当动画结束时,edittext宽度变为第一大小.
谁能帮我.?
有没有解决方案在动画中将"fillparent"设置为宽度的最终大小?
Animation scaleAnimation = new ScaleAnimation(0, -500, 1, 1);
scaleAnimation.setDuration(750);
editText.startAnimation(scaleAnimation);
Run Code Online (Sandbox Code Playgroud)
我scaleAnimation.setFillAfter(true);在动画开始之前添加了但是我得到了这个;

在750ms之后,edittext将转到第一个宽度.
这绝对适合你.
动态的方式:
ScaleAnimation animate = new ScaleAnimation(1, 2, 1, 1, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
animate.setDuration(700);
animate.setFillAfter(true);
target.startAnimation(animate);
Run Code Online (Sandbox Code Playgroud)
使用XML的方式
scale.xml(把它放在res/anim文件夹中)
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="400"
android:fillAfter="true"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="0%"
android:pivotY="0%"
android:toXScale="2.0"
android:toYScale="1.0" >
</scale>
</set>
Run Code Online (Sandbox Code Playgroud)
Java代码:
Animation anim = AnimationUtils.loadAnimation(Anims.this, R.anim.scale);
mEdittext.startAnimation(anim);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8511 次 |
| 最近记录: |