वहाँ में app:hintAnimationEnabled="false"
जोड़ने
यहाँ मैं अब तक किया है इसे प्राप्त करने के तीन तरीके हो सकते हैं:
TextInputLayout
पर _
वर्ण पर सेट करें, और android:hint="This is my cool hint"
EditText
पर सेट रखें।
<android.support.design.widget.TextInputLayout
....
....
android:hint=" "> <<----------
<EditText
....
....
android:hint="This is my cool hint"/> <<----------
</android.support.design.widget.TextInputLayout>
यह काम करता है क्योंकि TextInputLayout
EditText's
संकेत उपयोग करने से पहले निम्नलिखित की जांच करता है:
// If we do not have a valid hint, try and retrieve it from the EditText
if (TextUtils.isEmpty(mHint)) {
setHint(mEditText.getHint());
// Clear the EditText's hint as we will display it ourselves
mEditText.setHint(null);
}
android:hint=" "
की स्थापना करके, if (TextUtils.isEmpty(mHint))
false
को मूल्यांकन करती है और EditText
इसके संकेत बरकरार रखती है।
<your.package.name.CTextInputLayout
....
.... > <<----------
<EditText
....
....
android:hint="This is my cool hint"/> <<----------
</your.package.name.CTextInputLayout>
:
public class CTextInputLayout extends TextInputLayout {
public CTextInputLayout(Context context) {
this(context, null);
}
public CTextInputLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (child instanceof EditText) {
// cache the actual hint
CharSequence hint = ((EditText)child).getHint();
// remove the hint for now - we don't want TextInputLayout to see it
((EditText)child).setHint(null);
// let `TextInputLayout` do its thing
super.addView(child, index, params);
// finally, set the hint back
((EditText)child).setHint(hint);
} else {
// Carry on adding the View...
super.addView(child, index, params);
}
}
}
फिर डिजाइन समर्थन पुस्तकालय से एक के बजाय अपने कस्टम CTextInoutLayout
का उपयोग करें:
दूसरा विकल्प TextInputLayout
उपवर्ग और उसके addView(View child, int index, ViewGroup.LayoutParams params)
विधि ओवरराइड करने के लिए किया जाएगा 3 तीसरा, और शायद सबसे सीधा-आगे तरीका निम्न कॉल करना होगा:
// remove hint from `TextInputLayout`
((TextInputLayout)findViewById(R.id.textContainer)).setHint(null);
// set the hint back on the `EditText`
// The passed `String` could also be a string resource
((EditText)findViewById(R.id.myEditText)).setHint("This is my cool hinttt.");
बेस्ट विचार प्रोग्राम के आप देने के लिए संकेत और textChange घटना समय editbox कि विचार आप मदद कर सकते हैं –
समस्या संकेत रंग है में अशक्त संकेत के बारे में बताएं है। कुछ टाइप करते समय यह सफेद हो जाता है। कृपया संकेत रंग बदलें या पृष्ठभूमि रंग बदलें। टाइप करते समय आपको संकेत दिखाई देगा। –