mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00

* fix padding on text-view & text-field text-base is now snapshotable view.android is now snapshotable * createNativeView returns the nativeView for android Fix image tests Implement test for image loaded from res:// EffectivePaddings updated when nativeView have some from its native theme
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import {
|
|
HtmlViewBase, htmlProperty
|
|
} from "./html-view-common";
|
|
|
|
export * from "./html-view-common";
|
|
|
|
export class HtmlView extends HtmlViewBase {
|
|
private _android: android.widget.TextView;
|
|
|
|
get android(): android.widget.TextView {
|
|
return this._android;
|
|
}
|
|
|
|
public _createNativeView() {
|
|
const textView = this._android = new android.widget.TextView(this._context);
|
|
// This makes the html <a href...> work
|
|
textView.setLinksClickable(true);
|
|
textView.setMovementMethod(android.text.method.LinkMovementMethod.getInstance());
|
|
return textView;
|
|
}
|
|
|
|
get [htmlProperty.native](): string {
|
|
return "";
|
|
}
|
|
set [htmlProperty.native](value: string) {
|
|
// If the data.newValue actually has a <a...> in it; we need to disable autolink mask
|
|
// it internally disables the coloring, but then the <a> links won't work.. So to support both
|
|
// styles of links (html and just text based) we have to manually enable/disable the autolink mask
|
|
let mask = 15;
|
|
if (value.search(/<a\s/i) >= 0) {
|
|
mask = 0;
|
|
}
|
|
this._android.setAutoLinkMask(mask);
|
|
this._android.setText(<any>android.text.Html.fromHtml(value));
|
|
}
|
|
} |