Skip to content

Commit 293d3d1

Browse files
committed
[Search] Sync dummy text view with text and hint changes in SearchView
1 parent 8c17b08 commit 293d3d1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 8 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,12 @@ private void setUpDummyToolbarForContainedAnimation() {
498498
dummyToolbar.setVisibility(View.INVISIBLE);
499499
}
500500

501-
private void setUpDummyTextForContainedAnimation(@StyleRes int textAppearanceResId) {
501+
private void setUpDummyTextForContainedAnimation(@StyleRes int textAppearanceResId, String text, String hint) {
502502
if (textAppearanceResId != NO_RES_ID) {
503503
TextViewCompat.setTextAppearance(dummyTextView, textAppearanceResId);
504504
}
505+
dummyTextView.setText(text);
506+
dummyTextView.setHint(hint);
505507
}
506508

507509
@Px
@@ -817,11 +819,13 @@ public void setText(@Nullable CharSequence text) {
817819
/** Sets the text of main {@link EditText}. */
818820
public void setText(@StringRes int textResId) {
819821
editText.setText(textResId);
822+
dummyTextView.setText(textResId);
820823
}
821824

822825
/** Clears the text of main {@link EditText}. */
823826
public void clearText() {
824827
editText.setText("");
828+
dummyTextView.setText("");
825829
}
826830

827831
/** Returns the hint of main {@link EditText}. */
@@ -833,11 +837,13 @@ public CharSequence getHint() {
833837
/** Sets the hint of main {@link EditText}. */
834838
public void setHint(@Nullable CharSequence hint) {
835839
editText.setHint(hint);
840+
dummyTextView.setHint(hint);
836841
}
837842

838843
/** Sets the hint of main {@link EditText}. */
839844
public void setHint(@StringRes int hintResId) {
840845
editText.setHint(hintResId);
846+
dummyTextView.setHint(hintResId);
841847
}
842848

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

0 commit comments

Comments
 (0)