diff --git a/ui/search-bar/search-bar.android.ts b/ui/search-bar/search-bar.android.ts index 7a2b97c4e..a09e857ac 100644 --- a/ui/search-bar/search-bar.android.ts +++ b/ui/search-bar/search-bar.android.ts @@ -33,19 +33,10 @@ function onTextFieldBackgroundColorPropertyChanged(data: dependencyObservable.Pr // register the setNativeValue callbacks (common.SearchBar.textFieldBackgroundColorProperty.metadata).onSetNativeValue = onTextFieldBackgroundColorPropertyChanged; - -function _changeSearchViewBackgroundColor(view: android.view.View, color: number) { - if (view != null) { - if (view instanceof android.widget.TextView) { - ( view).setBackgroundColor(color); - return; - } else if (view instanceof android.view.ViewGroup) { - var viewGroup = view; - for (var i = 0; i < viewGroup.getChildCount(); i++) { - _changeSearchViewBackgroundColor(viewGroup.getChildAt(i), color); - } - } - } +function _changeSearchViewBackgroundColor(bar: android.widget.SearchView, color: number) { + var id = bar.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); + var textView = bar.findViewById(id); + textView.setBackgroundColor(color); } // merge the exports of the common file with the exports of this file diff --git a/ui/styling/stylers.android.ts b/ui/styling/stylers.android.ts index 56e4b27b4..fd96070dd 100644 --- a/ui/styling/stylers.android.ts +++ b/ui/styling/stylers.android.ts @@ -244,11 +244,13 @@ export class SearchBarStyler implements definition.stylers.Styler { private static setBackgroundColorProperty(view: view.View, newValue: any) { var bar = view.android; bar.setBackgroundColor(newValue); + SearchBarStyler._changeSearchViewPlateBackgroundColor(bar, newValue); } private static resetBackgroundColorProperty(view: view.View, nativeValue: any) { var bar = view.android; bar.setBackgroundColor(nativeValue); + SearchBarStyler._changeSearchViewPlateBackgroundColor(bar, nativeValue); } private static setColorProperty(view: view.View, newValue: any) { @@ -271,18 +273,16 @@ export class SearchBarStyler implements definition.stylers.Styler { SearchBarStyler.resetColorProperty), "SearchBar"); } - private static _changeSearchViewTextColor(view: android.view.View, color: number) { - if (view != null) { - if (view instanceof android.widget.TextView) { - ( view).setTextColor(color); - return; - } else if (view instanceof android.view.ViewGroup) { - var viewGroup = view; - for (var i = 0; i < viewGroup.getChildCount(); i++) { - SearchBarStyler._changeSearchViewTextColor(viewGroup.getChildAt(i), color); - } - } - } + private static _changeSearchViewTextColor(bar: android.widget.SearchView, color: number) { + var id = bar.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); + var textView = bar.findViewById(id); + textView.setTextColor(color); + } + + private static _changeSearchViewPlateBackgroundColor(bar: android.widget.SearchView, color: number) { + var id = bar.getContext().getResources().getIdentifier("android:id/search_plate", null, null); + var textView = bar.findViewById(id); + textView.setBackgroundColor(color); } }