Pau*_*Zin 16 android android-support-library
我正在使用Android Design Library中的TextInputLayout在EditText上显示标签.
问题是当我开始活动时,EditText提示(标签)文本与实际文本重叠(一秒钟),然后返回到它自己的位置(在EditText的顶部).
为了说明这个问题,我录制了一个简短的示例视频:https://youtu.be/gy0CzcYggxU
这是我的activity.xml:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/firstNameTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/firstNameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/first_name"
android:inputType="textCapWords"
android:textColor="@color/textPrimary"
android:textColorHint="@color/textSecondary"
android:textSize="16sp"
android:theme="@style/CustomEditText"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp">
<EditText
android:id="@+id/lastNameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/last_name"
android:inputType="textCapWords"
android:textColor="@color/textPrimary"
android:textColorHint="@color/textSecondary"
android:textSize="16sp"
android:theme="@style/CustomEditText"/>
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
终于找到了对该问题的充分解释:
事实证明,Android 4.0 中的框架添加了一项性能优化,它允许您的视图层次结构在 Activity 动画开始之前仅执行一次绘制过程。一旦 Activity 动画结束,您的视图层次结构就会按照您的预期每 16 毫秒绘制一次。
了解更多: https: //medium.com/@chrisbanes
TLDR:这是平台限制,这种行为会发生在旧版本(Marshmallow 及更低版本)上。
在牛轧糖上,动画将按预期运行,不会出现延迟。