简体   繁体   English

如何从中心对EditText进行动画处理

[英]How to Animate an EditText from the Center

So I want to animate my EditText (ET) to expand. 所以我想给我的EditText (ET)设置动画以进行扩展。 Plain and simple right. 简单明了的权利。 Well I can do it with the following code but that is from (left of ET stays in the same position, right of ET expands outwards). 我可以使用下面的代码来做到这一点,但这是从(ET的左侧保持相同位置,ET的右侧向外扩展)开始的。 I would like it from the center where left and right of ET expands outwards then on any other ?Gesture or touch of anywhere? 我想从ET的左右两侧向外扩展的中心,然后在任何其他位置进行手势或触摸? not the ET itself, it closes(shrinks) to original size in a animate way. 而不是ET本身,它以动画方式关闭(缩小)到原始大小。 Is there a way to do the following or a library that can help simplify this. 有没有一种方法可以执行以下操作或提供一个可以简化此操作的库。 If so leave a link all comments will be appreciated due to my entry level knowledge. 如果是这样,留下一个链接,由于我的入门级知识,所有评论将不胜感激。

<?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>

to start the animation from the center make 从中心开始制作动画

android:pivotX="50%"
android:pivotY="50%"

However with you code you are starting the animation from it's original view scale than expand it, you should animate the view from smaller scale to the original scale it should be something like that. 但是,使用代码时,您是从动画的原始视图比例开始制作动画,而不是对其进行扩展,因此应该将视图从较小的比例动画化为原始比例,就像这样。

android:fromXScale="0.0"
android:fromYScale="1.0"
android:toXScale="1.0"
android:toYScale="1.0"
....

however, if you want to keep the old code for some reason make sure your editText container in xml is wide enough you don't want your editText to interface with other views 但是,如果出于某种原因要保留旧代码,请确保xmleditText容器足够宽,您不希望您的editText与其他视图交互

You EditText in xml sholud be 您在xml EditText

android:layout_width="you_width"
android:layout_height="wrap_content"
android:minLines="1"
....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM