2

안녕하세요. 나는 문제가있다. 포커스가있을 때 EditText 드로어 블의 색상을 변경하고 포커스가 변경되면 다시 기본 색상으로 변경합니다. 지원 라이브러리가 업데이트 될 때까지 모든 것이 좋았습니다. (그것이 제 가정입니다.) 드로어 블의 색상이 정상으로 돌아 가지 않습니다. 사전에 감사의 모두가 =)edittext에서 드로어 블에서 색조 색을 제거하는 방법은 무엇입니까?

이 내 코드입니다 :

@Override 
public Drawable setTint(Drawable d, int color) { 
    Drawable wrappedDrawable = DrawableCompat.wrap(d); 
    DrawableCompat.setTint(wrappedDrawable, color); 
    return wrappedDrawable; 
} 

@Override 
public void setEditTextDrawables(final EditText editText, final int drawable) { 
    editText.setCompoundDrawablesWithIntrinsicBounds(drawable, 0, 0, 0); 
    editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
     @Override 
     public void onFocusChange(View view, boolean b) { 
      if (b){ 
       Drawable icon = getResources().getDrawable(drawable); 
       editText.setCompoundDrawablesWithIntrinsicBounds(setTint(icon, 
         getResources().getColor(R.color.colorAccent)), null, null, null); 
      }else if (!b){ 
       Drawable icon = getResources().getDrawable(drawable); 
       editText.setCompoundDrawablesWithIntrinsicBounds(setTint(icon, 
         getResources().getColor(R.color.colorGreyIcon)), null, null, null); 
      } 
     } 
    }); 
} 

이 앱에서 화면입니다 :

enter image description here

enter image description here

+0

"만약 (나) 다른 경우 (나!)"에 그냥 "경우 (b)는 다른". – Funktional

답변

0

setTintList(null)은 21 이상 (Android 5.0, Lollipop)의 API에서만 작동합니다. 따라서 ImageViewCompat의 사용이 권장됩니다 : 당신은 당신의 코드를 단순화 할 수 Aside-

ImageViewCompat.setImageTintList(iv,null); 
관련 문제