2016-12-16 49 views
1

我已經應用了android TextInputLayout,它工作正常。但是當出現文本輸入佈局時,編輯文本變得非常慢。以及我已經改變了提示顏色,但它不工作。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'

+0

你是怎麼改變的暗示色彩? –

回答

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

集的改變暗示的顏色,我可以看到你的代碼爲什麼文本變得非常慢找到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
<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> 
+0

這個鏈接將幫助你,「http://stackoverflow.com/questions/30546430/how-to-change-the-floating-label-color-of-textinputlayout」 –