Android键盘隐藏TextView元素NativeScript



当我试图在屏幕底部的TextView元素中编写内容时,Android键盘会隐藏该元素。如何解决此问题?我已经尝试过在我的清单中添加"adjustPan"和其他选项,但不幸的是,它不起作用。知道吗?

我的XML:

<topbar></topbar>
<GridLayout rows="auto,*">
<subnav row="0"></subnav>
<ScrollView row="1" orientation="vertical" height="100%">
<GridLayout rows="*" height="100%">
<ListView #chatList *ngIf="chat && chat.messages && chat.messages.length" iosEstimatedRowHeight="0" separatorColor="transparent" (loadMoreItems)="onResetMoreButtonPressed()" [items]="chat.messages" marginTop="60" marginBottom="120">
<ng-template nsTemplateKey="item" let-item="item" let-i="index">
<!--<GridLayout
[rows]="i == 0 ? 'auto,20,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,10,5' : (i == (chat.messages.length - 1) ? '5,20,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,10,200' : '5,20,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,auto,10,5')"
columns="10,10,30%,10,*,10,30%,10,10"
[i]="i"
[showMoreButton]="showMoreButton"
[chatItem]="item"
(loadMore)="onLoadMore()"
(setReply)="onReply($event)"
chat-grid-item>
</GridLayout>-->
<StackLayout
[i]="i"
[showMoreButton]="showMoreButton"
[chatItem]="item"
(loadMore)="onLoadMore()"
(setReply)="onReply($event)"
chat-grid-item>
</StackLayout>
</ng-template>
</ListView>
<GridLayout rows="10,auto,10,auto" columns="10,*,10,auto,10,auto,10,auto,10,auto,10,auto,10" class="mat-bg-warn" horizontalAlignment="center" verticalAlignment="top" width="100%">
<Label row="1" col="5" (tap)="onToggleFavorite()" verticalAlignment="top" textAlignment="center" class="material-icons material-icons-main mat-bg-background-menu" text="&#xe838;" [backgroundColor]="(chat && chat.is_favorite ? environmentService.customer.colors.warn : '')" [color]="(chat && chat.is_favorite ?  environmentService.customer.colors.warn_font : '')"></Label>
<Label row="1" col="7" *ngIf="chat && chat.is_editable" (tap)="onChatEdit()" verticalAlignment="top" textAlignment="center" class="material-icons material-icons-main mat-bg-background-menu" text="&#xE8B8;"></Label>
<Label row="1" col="7" *ngIf="chat && !chat.is_editable" (tap)="onChatEdit()" verticalAlignment="top" textAlignment="center" class="material-icons material-icons-main mat-bg-background-menu" text="&#xE7FF;"></Label>
<Label row="1" col="9" (tap)="onQuitChat()" verticalAlignment="top" textAlignment="center" class="material-icons material-icons-main mat-bg-background-menu" text="&#xE879;"></Label>
<Label row="1" col="11" (tap)="drawerService.onNavigateTo('chat')" verticalAlignment="top" textAlignment="center" class="material-icons material-icons-main mat-bg-background-menu" text="&#xE314;"></Label>
<Label row="1" col="1" *ngIf="chat && chat.name && chat.users" class="h2 mat-font-warn" verticalAlignment="top" marginTop="3" [text]="chat.name + '(' + chat.users.length + ')'"></Label>
<label row="3" col="0" colSpan="13" class="error" [text]="'CHAT_ALONE' | translate" *ngIf="chat && chat.users && chat.users.length && chat.users.length <= 1"></label>
</GridLayout>
<GridLayout rows="5,105,5" columns="5,auto,32,5,*,5,32,5" class="mat-bg-background-menu" [formGroup]="formGroup" horizontalAlignment="center" verticalAlignment="bottom">
<Label row="1" col="1"  *ngIf="!confirmDelete && formService.share_object && formService.share_type == 'mapp'" (tap)="confirmDelete = true" verticalAlignment="top" textAlignment="center" class="material-icons material-icons-main mat-bg-warn" text="&#xe157;" marginRight="5"></Label>
<Label row="1" col="1"  *ngIf="confirmDelete && formService.share_object && formService.share_type == 'mapp'" (tap)="onConfirmShareDelete()" verticalAlignment="top" textAlignment="center" class="material-icons material-icons-main mat-bg-warn" text="&#xe872;" marginRight="5"></Label>
<Label row="1" col="2" (tap)="onFilesEdit()" verticalAlignment="top" textAlignment="center" class="material-icons material-icons-main mat-bg-warn" text="&#xe2cc;"></Label>
<Label row="1" col="2" (tap)="onFilesEdit()" [text]="fileData.length" verticalAlignment="top" class="material-icons-info mat-bg-background-menu"></Label>
<TextView formControlName="reply" row="1" col="4" width="100%" height="100" class="input-field" (focus)="onInputFocus()" (textChange)="onInputChange()"></TextView>
<Label row="1" col="6" (tap)="onCreate()" verticalAlignment="top" textAlignment="center" class="material-icons material-icons-main mat-bg-warn" text="&#xE163;"></Label>
</GridLayout>
</GridLayout>
</ScrollView>
<ActivityIndicator rowSpan="2" [busy]="loading" class="spinner mat-color-warn mat-bg-background" height="100%"></ActivityIndicator>

我的清单.xml:

<activity-alias
android:name=".Launcher"
android:targetActivity="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
android:theme="@style/LaunchScreenTheme"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:exported="true"
android:enabled="true"
android:windowSoftInputMode="adjustPan">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>

您需要在该特定活动的清单文件中添加标志windowSoftInputMode="adjustPan"

例如:

<activity
android:name=".MainActivity"
android:windowSoftInputMode="adjustPan"
</activity>

希望它能有所帮助:(

相关内容

  • 没有找到相关文章

最新更新