拉伸动画EditText

时间:2018-01-12 23:33:25

标签: android animation android-edittext

我有一个Editext动画形式双方扩展单词。这样做是拉伸的,看起来有点偏离(文字较大,角的半径变为更高的值,你不会看到输入的前3.5个字符)我想知道是否有另一种方法与另一个动画文件或者做这个动画的另一种方式。我想解决的第二个问题,但如果我不能解决mUrlSearch.ClearAnimation的问题。我希望它更平滑,然后在宽度上大胆重置。

EditText_Scale.xml

<scale
android:duration="400"
android:fillAfter="true"
android:fromXScale="0.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="2.0"
android:toYScale="1.0"
</scale>

</set>

main_header.XML

<android.support.constraint.ConstraintLayout

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mHeader"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@android:color/transparent">


<EditText
    android:id="@+id/mUrlSearch"
    android:layout_width="150dp"
    android:layout_height="25dp"
    android:layout_marginBottom="1dp"
    android:background="@drawable/edittext_rounded"
    android:textSize="12px"
    android:textColor="#000"

    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<Button
    android:id="@+id/m_Preferences"
    android:layout_width="wrap_content"
    android:layout_height="10dp"
    android:layout_marginBottom="21dp"
    android:layout_marginStart="17dp"
    android:background="@drawable/preference_round"
    android:textSize="12px"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@+id/mUrlSearch"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="1.0" />

</android.support.constraint.ConstraintLayout>

activity_main.xml中

<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"



android:id="@+id/mainPage"
android:layout_width="match_parent"
android:layout_height="match_parent"

tools:context="com.equiware.mickeyt.unite.MainActivity">

<WebView
    android:id="@+id/mWebView"
    android:layout_width="362dp"
    android:layout_height="570dp"

    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="1.0">


</WebView>

<include
    android:id="@+id/mHeader"
    layout="@layout/main_header"
    android:layout_width="360dp"
    android:layout_height="35dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0">


</include>

</android.support.constraint.ConstraintLayout>

主要.java部分

    mUrlSearch.setOnFocusChangeListener(new OnFocusChangeListener(){

        public void onFocusChange(View v,boolean hasFocus){
            if (mUrlSearch.isFocused()) {
                Animation anim = AnimationUtils.loadAnimation(MainActivity.this, R.anim.edittext_scale);
                mUrlSearch.startAnimation(anim);
            }
            else
            {
            mUrlSearch.clearAnimation();
            }
        }
    });

0 个答案:

没有答案