TextInputLayout浮动标签出现缓慢

3

我已经应用了Android的TextInputLayout,它可以正常工作。但是当出现文本输入布局时,编辑文本会变得非常缓慢。此外,我已经更改了提示颜色,但它没有起作用。

布局xml:

 <android.support.design.widget.TextInputLayout
                android:id="@+id/register_input_layout_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:maxLength="15"
                android:lines="1"
                android:id="@+id/Register_fragment_passwo_field"
                android:hint="Password"
                android:layout_gravity="center_vertical"
                android:paddingLeft="35dp"
                android:textColor="#ffffff"
                android:textColorHint="@android:color/white"
                android:layout_marginTop="5dp" />
            </android.support.design.widget.TextInputLayout>

依赖关系 : compile 'com.android.support:design:23.0.1'


你是如何改变提示颜色的? - Charuක
3个回答

0

设置TextInputLayout的这个属性android:textColorHint="@android:color/white"可以改变提示文字的颜色,能否让我看一下你查找文本变得非常缓慢的代码。

<android.support.design.widget.TextInputLayout
                    android:id="@+id/register_input_layout_password"
                    android:layout_width="match_parent"
                    android:textColorHint="@android:color/white"
                    android:layout_height="wrap_content">
                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:maxLength="15"
                    android:lines="1"
                    android:id="@+id/Register_fragment_passwo_field"
                    android:hint="Password"
                    android:layout_gravity="center_vertical"
                    android:paddingLeft="35dp"
                    android:textColor="#ffffff"
                    android:textColorHint="@android:color/white"
                    android:layout_marginTop="5dp" />
                </android.support.design.widget.TextInputLayout>

0
   <!-- if You Can Change Color of TextInputLayout Like this-->
    <style name="TextLabel" parent="TextAppearance.AppCompat">
        <!-- Hint color and label color in FALSE state -->
        <item name="android:textColorHint">@color/Color Name</item> 
        <item name="android:textSize">20sp</item>
        <!-- Label color in TRUE state and bar color FALSE and TRUE State -->
        <item name="colorAccent">@color/Color Name</item>
        <item name="colorControlNormal">@color/Color Name</item>
        <item name="colorControlActivated">@color/Color Name</item>
     </style>

如果您更改动画时间,则可以按照以下方式自定义EditText
public class FloatingEditText extends FrameLayout{

      animation = new AnimatorSet();
      ObjectAnimator move =
          ObjectAnimator.ofFloat(mHintTextView, "translationY", mHintTextView.getHeight() / 8, 0);
      ObjectAnimator fade;
      if (mEditText.isFocused()) {
        fade = ObjectAnimator.ofFloat(mHintTextView, "alpha", 0, 1);
      } else {
        fade = ObjectAnimator.ofFloat(mHintTextView, "alpha", 0, 0.50f);
      }
      animation.playTogether(move, fade);
}

0
 <android.support.design.widget.TextInputLayout
                android:id="@+id/il_second_phone_number"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/view_margin_micro"
                android:textColorHighlight="@color/color_darker_gray"
                android:textColorHint="@color/color_darker_gray">

                <EditText
                    android:id="@+id/et_second_phone_number"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/layout_height_normal"
                    android:backgroundTint="@color/color_darker_gray"
                    android:hint="@string/second_phone_number"
                    android:inputType="phone"
                    android:maxLines="1"
                    android:text="@={vm.cPhoneTwo}"
                    android:textColor="@color/color_black" />
            </android.support.design.widget.TextInputLayout>

这个链接会对你有所帮助,"https://dev59.com/Ul0a5IYBdhLWcg3wPWpN"。 - Mahesh Kedari

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接