[英]How to Animate an EditText from the Center
所以我想給我的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>
從中心開始制作動畫
android:pivotX="50%"
android:pivotY="50%"
但是,使用代碼時,您是從動畫的原始視圖比例開始制作動畫,而不是對其進行擴展,因此應該將視圖從較小的比例動畫化為原始比例,就像這樣。
android:fromXScale="0.0"
android:fromYScale="1.0"
android:toXScale="1.0"
android:toYScale="1.0"
....
但是,如果出於某種原因要保留舊代碼,請確保xml
的editText
容器足夠寬,您不希望您的editText
與其他視圖交互
您在xml
EditText
是
android:layout_width="you_width"
android:layout_height="wrap_content"
android:minLines="1"
....
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.