Skip to content

Commit 87b98eb

Browse files
pubiqqdsn5ft
authored andcommitted
[Search] Sync dummy text view with text and hint changes in SearchView
Resolves #5072 - 293d3d1 by pubiqq <serj.ese@gmail.com> PiperOrigin-RevId: 904944212
1 parent abc118f commit 87b98eb

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/java/com/google/android/material/search/SearchView.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public SearchView(@NonNull Context context, @Nullable AttributeSet attrs, int de
270270

271271
if (containedAnimationEnabled) {
272272
setUpDummyToolbarForContainedAnimation();
273-
setUpDummyTextForContainedAnimation(textAppearanceResId);
273+
setUpDummyTextForContainedAnimation(textAppearanceResId, text, hint);
274274
}
275275
}
276276

@@ -498,10 +498,13 @@ private void setUpDummyToolbarForContainedAnimation() {
498498
dummyToolbar.setVisibility(View.INVISIBLE);
499499
}
500500

501-
private void setUpDummyTextForContainedAnimation(@StyleRes int textAppearanceResId) {
501+
private void setUpDummyTextForContainedAnimation(
502+
@StyleRes int textAppearanceResId, String text, String hint) {
502503
if (textAppearanceResId != NO_RES_ID) {
503504
TextViewCompat.setTextAppearance(dummyTextView, textAppearanceResId);
504505
}
506+
dummyTextView.setText(text);
507+
dummyTextView.setHint(hint);
505508
}
506509

507510
@Px
@@ -817,11 +820,13 @@ public void setText(@Nullable CharSequence text) {
817820
/** Sets the text of main {@link EditText}. */
818821
public void setText(@StringRes int textResId) {
819822
editText.setText(textResId);
823+
dummyTextView.setText(textResId);
820824
}
821825

822826
/** Clears the text of main {@link EditText}. */
823827
public void clearText() {
824828
editText.setText("");
829+
dummyTextView.setText("");
825830
}
826831

827832
/** Returns the hint of main {@link EditText}. */
@@ -833,11 +838,13 @@ public CharSequence getHint() {
833838
/** Sets the hint of main {@link EditText}. */
834839
public void setHint(@Nullable CharSequence hint) {
835840
editText.setHint(hint);
841+
dummyTextView.setHint(hint);
836842
}
837843

838844
/** Sets the hint of main {@link EditText}. */
839845
public void setHint(@StringRes int hintResId) {
840846
editText.setHint(hintResId);
847+
dummyTextView.setHint(hintResId);
841848
}
842849

843850
/** Returns the current value of this {@link SearchView}'s soft input mode. */

0 commit comments

Comments
 (0)