我尝试了几种不同的方法让我的文本字段停止专注于页面加载。页面加载时键盘不会显示,但字段的标签向上移动就好像它处于焦点一样。我尝试了link顶部的建议,但该领域仍然是焦点。 onPageLoad
我还通过Id检索了TextField,然后调用了setFocusable(false)
,但这完全阻止了我再次关注元素。并且android的clearFocus
也没有做任何事情,因为该元素仍然试图集中注意力。如何让该领域停止专注于Android?它侧重于页面加载时的电子邮件地址字段。
<Page
backgroundSpanUnderStatusBar="false"
backgroundColor="#222222"
loaded="onPageLoaded"
class="page"
actionBarHidden="true"
xmlns:Gradient="nativescript-gradient"
xmlns:TIL="nativescript-textinputlayout">
<GridLayout rows="*, auto, auto" columns="*">
<GridLayout row="0" col="0" rows="auto, auto" columns="*" verticalAlignment="bottom" style="margin-bottom: 64dp;">
<StackLayout row="0" col="0" style="margin-bottom: 16dp;">
<Label class="h1 registration-app-title" horizontalAlignment="center" verticalAlignment="bottom" textWrap="true" text="Repeat"/>
</StackLayout>
<StackLayout row="1" col="0">
<Label class="h3 registration-app-description" horizontalAlignment="center" verticalAlignment="bottom" textWrap="true" text="Save articles to your playlist and listen to them anywhere."/>
</StackLayout>
</GridLayout>
<GridLayout row="1" col="0" rows="*, *, *, *" columns="*, *" class="registration-bottom">
<StackLayout orientation="vertical" class="form" row="0" col="0" colSpan="2">
<TIL:TextInputLayout
class="text-input-layout"
hint="E-mail Address"
hintTextAppearance="StyledTIL"
>
<TextField
id="text-field-email"
text="{{ email }}"
autocorrect="false"
autocapitalizationType="none"
keyboardType="email"
returnKeyType="next"/>
</TIL:TextInputLayout>
<TIL:TextInputLayout
class="text-input-layout"
hint="Password"
hintTextAppearance="StyledTIL"
marginBottom="30dp">
<TextField
id="text-field-password"
text="{{ password }}"
secure="true"
autocapitalizationType="none"
returnKeyType="done"/>
</TIL:TextInputLayout>
</StackLayout>
<StackLayout orientation="horizontal" class="form" row="1" col="0" colSpan="2" style="width: 80%;">
<Gradient:Gradient direction="to right" colors="#FF51A0FF, #FF3F2AFF" class="gradient" style="margin-right: 14;">
<Button class="btn btn-primary"
id="register-email"
text="Sign Up"
tap="register" />
</Gradient:Gradient>
<Gradient:Gradient direction="to right" colors="#FF51A0FF, #FF3F2AFF" class="gradient">
<Button class="btn btn-primary"
id="email"
text="Log In"
tap="authenticate"/>
</Gradient:Gradient>
</StackLayout>
<StackLayout orientation="vertical" class="form" row="2" col="0" colSpan="2">
<Button class="btn btn-alternate"
id="facebook"
text="Connect with Facebook"
tap="authenticate"
textTransform="none"/>
<Button class="btn btn-alternate"
id="google"
text="Connect with Google"
tap="authenticate"
textTransform="none" />
</StackLayout>
<GridLayout row="3" col="0" colSpan="2" rows="*" columns="*">
<Label class="h3 skip-step-label"
id="anonymous"
row="0"
col="0"
text="Skip this step"
tap="authenticate"/>
</GridLayout>
</GridLayout>
</GridLayout>
</Page>
答案 0 :(得分:0)
尝试在您网页dismissSoftInput
活动中的utils模块中调用navigatedTo
。
import { ad } as utils from "utils/utils";
ad.dismissSoftInput();
更新:以上只会隐藏键盘,不会完全移除焦点。您总是需要另一个可以聚焦的视图,以便从TextField中移除焦点。这是一个如何做到这一点的例子,