-5

私は2つの編集テキストを持っています。最初は電子メールで、もう1つはパスワードフィールドです。
両方のフィールドに入力せずに[ログイン]ボタンをクリックすると、両方のフィールドのヒントカラーと下線の変更が非合焦状態になります。
リンク先ページにピントが合っていない状態では、色は青色である必要があります。enter image description here 非フォーカス状態のフィールドを入力せずにログインをクリックするとenter image description hereとなります。編集テキストが空で、アンドロイドにフォーカスがない場合、ヒントの色、下線の色ヒントテキストを変更するにはどうすればよいですか?

これは私の必要条件です。
私は、このシナリオを達成するために可能なすべての方法を試しました。
しかし、私は制御焦点が合っていて、焦点が合っていない状態です。
この問題を解決するために私を案内してください。

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="colorControlActivated">@color/primary</item> <item name="colorControlHighlight">@color/colorPrimary</item> </style> 

ヒントカラーを変更し、アンダーラインの色をプログラムに基づいて非合焦状態に変更したいと考えています。

colors.xml

<resources> <color name="primary">#1976d2</color> <color name="primary_dark">#E12929</color> <color name="primary_darker">#CC1D1D</color> <color name="accent">#000000</color> <color name="blue">#1976d2</color> <color name="black">#000000</color> <color name="lightblue">#1976d2</color> <color name="lightgray">#666666</color> </resources> 
+0

使用TextInputLayout – MinnuKaAnae

+0

。 styles.xmlとcolors.xmlを投稿します。 – MinnuKaAnae

+0

user8367573

答えて

0

あなたのような何かが、このような以下のものを試してみてくださいについては、エラーを作る

TextInputLayout emailInput, passInput; 
EditText edtEmail, edtPass; 
Button btnLogin; 
String hintEmail = "",hintPass=""; 


emailInput = (TextInputLayout) findViewById(R.id.emailInput); 
passInput = (TextInputLayout) findViewById(R.id.passInput); 

edtEmail = (EditText) findViewById(R.id.edtEmail); 
edtPass = (EditText) findViewById(R.id.edtPass); 

btnLogin = (Button) findViewById(R.id.btnLogin); 
btnLogin.setOnClickListener(this); 


    btnLogin.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      if (edtEmail.getText().toString().trim().isEmpty()) { 
       edtEmail.setHint("please enter Email Address "); 
       hintEmail = "please enter Email Address "; 
       edtEmail.setHintTextColor(ContextCompat.getColor(this,R.color.colorRed)); 
       emailInput.setHint(""); 

      } 

      if (edtPass.getText().toString().trim().isEmpty()) { 
       edtPass.setHint("please enter Password "); 
       hintPass = "please enter Password "; 
       edtPass.setHintTextColor(getResources().getColor(R.color.colorRed)); 
       passInput.setHint(""); 

      } 

     } 
    }); 
    edtEmail.setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View view, MotionEvent motionEvent) { 
      emailInput.setHint(hintEmail); 
      edtEmail.setHint(""); 
      return false; 
     } 
    }); 
    edtPass.setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View view, MotionEvent motionEvent) { 
      passInput.setHint(hintPass); 
      edtPass.setHint(""); 
      return false; 
     } 
    }); 
0

試してみてください削除する必要がある状態をsetErrorEnabled(false)

着陸は、それはあなたがcolors.xmlで述べたあなたのcolorprimaryであることを意味する青い
inputLayout_et = (TextInputLayout) findViewById(R.id.input_layout_newpassword); 

    inputLayout_et.setErrorEnabled(false); 
+0

ありがとうNilesh ..しかし、私もそれを試してみました..私は焦点が合っていない状態でヒントの色を変更したい。しかし、TextInputLayoutでは、 – user8367573

+0

@ user8367573 [このリンクをチェック](https://stackoverflow.com/questions/38327430/textinputlayout-different-color-for-hint-label-when-not-focused)それはあなたを助けるでしょう –

+0

私は編集のテキストをカスタマイズする必要があります。 – user8367573

0

これは検証後に使用inputLayout.setError("Enther somehting");をEDITTEXTしよう

<android.support.design.widget.TextInputLayout 
android:id="@+id/usernameWrapper" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

<EditText 
    android:id="@+id/username" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textEmailAddress" 
    android:hint="Username"/> 

</android.support.design.widget.TextInputLayout> 
0

ヒント色

android:textColorHint="@color/red" 
+0

これは質問に対する答えを提供しません。批評をしたり、著者の説明を求めるには、投稿の下にコメントを残してください。 - [レビューから](/レビュー/低品質の投稿/ 16830591) –

+0

はいMr.ric..ソリューションは何ですか? – user8367573

+0

あなたはスタイルで追加できます –

関連する問題