mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
* Use AppCompat SearchView * GetNative elements for appcompat * Classes renamed * test modified
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import * as colorModule from "tns-core-modules/color";
|
|
import * as searchBarModule from "tns-core-modules/ui/search-bar";
|
|
import * as utils from "tns-core-modules/utils/utils";
|
|
|
|
function getTextView(bar: android.widget.SearchView): android.widget.TextView {
|
|
if (bar) {
|
|
const pkgName = bar.getContext().getPackageName();
|
|
var id = bar.getContext().getResources().getIdentifier("search_src_text", "id", pkgName);
|
|
if (id) {
|
|
return <android.widget.TextView>bar.findViewById(id);
|
|
}
|
|
}
|
|
|
|
return undefined;
|
|
}
|
|
|
|
export function getNativeHintColor(searchBar: searchBarModule.SearchBar): colorModule.Color {
|
|
var textView = getTextView(searchBar.android);
|
|
|
|
if (textView) {
|
|
return new colorModule.Color(textView.getHintTextColors().getDefaultColor());
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
export function getNativeFontSize(searchBar: searchBarModule.SearchBar): number {
|
|
var textView = getTextView(searchBar.android);
|
|
|
|
if (textView) {
|
|
return textView.getTextSize() / utils.layout.getDisplayDensity();
|
|
}
|
|
return undefined;
|
|
}
|