@@ -2266,22 +2266,8 @@ private static void updateCounterContentDescription(
22662266 * @see #getPlaceholderText()
22672267 */
22682268 public void setPlaceholderText (@ Nullable final CharSequence placeholderText ) {
2269- if (placeholderTextView == null ) {
2270- placeholderTextView = new AppCompatTextView (getContext ());
2271- placeholderTextView .setId (R .id .textinput_placeholder );
2272- ViewCompat .setImportantForAccessibility (
2273- placeholderTextView , ViewCompat .IMPORTANT_FOR_ACCESSIBILITY_NO );
2274-
2275- placeholderFadeIn = createPlaceholderFadeTransition ();
2276- placeholderFadeIn .setStartDelay (PLACEHOLDER_START_DELAY );
2277- placeholderFadeOut = createPlaceholderFadeTransition ();
2278-
2279- setPlaceholderTextAppearance (placeholderTextAppearance );
2280- setPlaceholderTextColor (placeholderTextColor );
2281- }
2282-
2283- // If placeholder text is null, disable placeholder.
2284- if (TextUtils .isEmpty (placeholderText )) {
2269+ // If placeholder text is null, disable placeholder if it's enabled.
2270+ if (placeholderEnabled && TextUtils .isEmpty (placeholderText )) {
22852271 setPlaceholderTextEnabled (false );
22862272 } else {
22872273 if (!placeholderEnabled ) {
@@ -2312,6 +2298,19 @@ private void setPlaceholderTextEnabled(boolean placeholderEnabled) {
23122298
23132299 // Otherwise, adjust enabled state.
23142300 if (placeholderEnabled ) {
2301+ placeholderTextView = new AppCompatTextView (getContext ());
2302+ placeholderTextView .setId (R .id .textinput_placeholder );
2303+
2304+ placeholderFadeIn = createPlaceholderFadeTransition ();
2305+ placeholderFadeIn .setStartDelay (PLACEHOLDER_START_DELAY );
2306+
2307+ placeholderFadeOut = createPlaceholderFadeTransition ();
2308+
2309+ ViewCompat .setAccessibilityLiveRegion (
2310+ placeholderTextView , ViewCompat .ACCESSIBILITY_LIVE_REGION_POLITE );
2311+
2312+ setPlaceholderTextAppearance (placeholderTextAppearance );
2313+ setPlaceholderTextColor (placeholderTextColor );
23152314 addPlaceholderTextView ();
23162315 } else {
23172316 removePlaceholderTextView ();
@@ -2345,9 +2344,6 @@ private void showPlaceholderText() {
23452344 TransitionManager .beginDelayedTransition (inputFrame , placeholderFadeIn );
23462345 placeholderTextView .setVisibility (VISIBLE );
23472346 placeholderTextView .bringToFront ();
2348- if (VERSION .SDK_INT >= VERSION_CODES .JELLY_BEAN ) {
2349- announceForAccessibility (placeholderText );
2350- }
23512347 }
23522348 }
23532349
0 commit comments