@nativescript/auto-fit-text
NativeScript 插件,用于使标签在单行中自动调整大小以适应屏幕。
npm i --save @nativescript/auto-fit-text

@nativescript/auto-fit-text

ns plugin add @nativescript/auto-fit-text

此插件基于 Nativescript Label 实现,但对字体大小进行了调整以适应标签的宽度

使用方法

Nativescript

<Page
xmlns="http://schemas.nativescript.org/tns.xsd"
loaded="pageLoaded"
class="page"
xmlns:AFT="@nativescript/auto-fit-text"
>

<StackLayout class="p-20">
<AFT:AutoFitText
text="Testinggggggggggggggggg"
textWrap="false"
>
</AFT:AutoFitText>
</StackLayout>
</Page>

Angular NativeScript

import { NativeScriptAutoFitTextModule } from '@nativescript/auto-fit-text/angular';

// Be sure to add the plugin module to your NgModule
@NgModule({
imports: [NativeScriptAutoFitTextModule],
})
<AutoFitText row="2" fontSize="48" text="Lorem Ipsum this line of text with fontSize ignored because the text is so long." textWrap="false"></AutoFitText>

致谢

@grantland - android-autofittextview

许可证

Apache 许可证第 2 版,2004 年 1 月