mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
styling for android search bar fixed
This commit is contained in:
@@ -33,19 +33,10 @@ function onTextFieldBackgroundColorPropertyChanged(data: dependencyObservable.Pr
|
||||
// register the setNativeValue callbacks
|
||||
(<proxy.PropertyMetadata>common.SearchBar.textFieldBackgroundColorProperty.metadata).onSetNativeValue = onTextFieldBackgroundColorPropertyChanged;
|
||||
|
||||
|
||||
function _changeSearchViewBackgroundColor(view: android.view.View, color: number) {
|
||||
if (view != null) {
|
||||
if (view instanceof android.widget.TextView) {
|
||||
(<android.widget.TextView> view).setBackgroundColor(color);
|
||||
return;
|
||||
} else if (view instanceof android.view.ViewGroup) {
|
||||
var viewGroup = <android.view.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 = <android.widget.TextView> bar.findViewById(id);
|
||||
textView.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
// merge the exports of the common file with the exports of this file
|
||||
|
||||
@@ -244,11 +244,13 @@ export class SearchBarStyler implements definition.stylers.Styler {
|
||||
private static setBackgroundColorProperty(view: view.View, newValue: any) {
|
||||
var bar = <android.widget.SearchView>view.android;
|
||||
bar.setBackgroundColor(newValue);
|
||||
SearchBarStyler._changeSearchViewPlateBackgroundColor(bar, newValue);
|
||||
}
|
||||
|
||||
private static resetBackgroundColorProperty(view: view.View, nativeValue: any) {
|
||||
var bar = <android.widget.SearchView>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) {
|
||||
(<android.widget.TextView> view).setTextColor(color);
|
||||
return;
|
||||
} else if (view instanceof android.view.ViewGroup) {
|
||||
var viewGroup = <android.view.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 = <android.widget.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 = <android.view.View> bar.findViewById(id);
|
||||
textView.setBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user