2016-07-29 5 views
0

私は多くを試み、R & Dをしましたが、EditTextの下で独自のカスタムエラーdrawableを表示することができませんでした。ここでEditTextの下にテキストのポップアップ

は私のコードです:

String str = "Please enter a valid email address”; 

// This line is used to give color to error text. 
ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.YELLOW); 

// This line is used to give background color to error text. 
BackgroundColorSpan backColorSpan = new BackgroundColorSpan(Color.BLUE); 

// This s basically a StringBuilder that implements CharSequence interface. 
SpannableStringBuilder strBuilder = new SpannableStringBuilder(str); 

strBuilder.setSpan(colorSpan, 0, str.length(), 0); 
EditText et = (EditText)findViewById(R.id.et); 
Drawable drawable = getResources().getDrawable(R.drawable.btn); 

// This line shows our own icon in place of default icon. 
setError(CharSequence, Drawable); 

So, strBuilder in next line is an implementation of CharSequence. 
et.setError(strBuilder, drawable); 

任意のソリューション?

+0

達成したいコードと画像を投稿できますか? – Mussa

答えて

0

をご確認ください。

drawableオブジェクトでsetBound()メソッドを呼び出す必要があります。 次の行を入力する必要があります。

drawable.setBounds(0,0,drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); 
+0

正常に動作しました。ありがとう。 –

関連する問題