Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nativescript 如何设置HtmlView的样式,例如居中文本?_Nativescript - Fatal编程技术网

Nativescript 如何设置HtmlView的样式,例如居中文本?

Nativescript 如何设置HtmlView的样式,例如居中文本?,nativescript,Nativescript,我正在使用HtmlView处理通过json提要获得的一些html文本。但是,我想把它放在图像的中心位置,我很难确定如何在视图中设置元素的样式。我知道如何设置元素本身的宽度,但如何设置内容的样式?使用“文本与样式对齐”属性 <HtmlView html="<div style='text-align: center'>this text should be in center of view</div>"></HtmlView> 这是一个游乐场的例

我正在使用HtmlView处理通过json提要获得的一些html文本。但是,我想把它放在图像的中心位置,我很难确定如何在视图中设置元素的样式。我知道如何设置元素本身的宽度,但如何设置内容的样式?

使用“文本与样式对齐”属性

<HtmlView html="<div style='text-align: center'>this text should be in center of view</div>"></HtmlView>
这是一个游乐场的例子

// Do this in loaded event of TextView
const nativeView = args.object.android;
if (nativeView) {
    nativeView.setGravity(android.view.Gravity.CENTER_HORIZONTAL);
}