如何从中心

时间:2018-01-10 01:46:09

标签: java android animation android-edittext gesture

所以我想动画我的EditText(ET)进行扩展。简单明了吧。好吧,我可以使用以下代码来完成它,但是来自(ET的左侧保持在相同的位置,ET的右侧向外扩展)。我希望从ET的左右两侧向外扩展,然后再向外扩展 ?任何地方的手势或触摸?不是ET本身,它以有生命的方式关闭(缩小)到原始大小。有没有办法做以下或一个可以帮助简化这个的库。如果是这样,请留下链接,由于我的入门级知识,所有评论都将受到赞赏。

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

1 个答案:

答案 0 :(得分:0)

从中心开始制作动画

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

然而,对于您的代码,您从原始视图比例开始动画而不是展开它,您应该将视图从较小比例设置为原始比例,它应该是类似的。

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

但是,如果您因某些原因想要保留旧代码,请确保editText中的xml容器足够宽,您不希望editText与其他视图对接

EditText中的xml sholud

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