Home > Enterprise >  Android Keyboard hides TextView Element NativeScript
Android Keyboard hides TextView Element NativeScript

Time:08-09

When I try to write something in an TextView-Element which is at the bottom of the screen, the Android keyboard hides the element. How can I resolve this issue? I already tried adding 'adjustPan' and other alternatives to my Manifest but it doesn't work unfortunately. Any idea?

My 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"  horizontalAlignment="center" verticalAlignment="top" width="100%">
            <Label row="1" col="5" (tap)="onToggleFavorite()" verticalAlignment="top" textAlignment="center"  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"  text="&#xE8B8;"></Label>
            <Label row="1" col="7" *ngIf="chat && !chat.is_editable" (tap)="onChatEdit()" verticalAlignment="top" textAlignment="center"  text="&#xE7FF;"></Label>
            <Label row="1" col="9" (tap)="onQuitChat()" verticalAlignment="top" textAlignment="center"  text="&#xE879;"></Label>
            <Label row="1" col="11" (tap)="drawerService.onNavigateTo('chat')" verticalAlignment="top" textAlignment="center"  text="&#xE314;"></Label>
            <Label row="1" col="1" *ngIf="chat && chat.name && chat.users"  verticalAlignment="top" marginTop="3" [text]="chat.name   '('   chat.users.length   ')'"></Label>

            <label row="3" col="0" colSpan="13"  [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"  [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"  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"  text="&#xe872;" marginRight="5"></Label>
            <Label row="1" col="2" (tap)="onFilesEdit()" verticalAlignment="top" textAlignment="center"  text="&#xe2cc;"></Label>
            <Label row="1" col="2" (tap)="onFilesEdit()" [text]="fileData.length" verticalAlignment="top" ></Label>
            <TextView formControlName="reply" row="1" col="4" width="100%" height="100"  (focus)="onInputFocus()" (textChange)="onInputChange()"></TextView>
            <Label row="1" col="6" (tap)="onCreate()" verticalAlignment="top" textAlignment="center"  text="&#xE163;"></Label>
        </GridLayout>
    </GridLayout>
</ScrollView>

<ActivityIndicator rowSpan="2" [busy]="loading"  height="100%"></ActivityIndicator>

My Manifest.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>

CodePudding user response:

You need to add flag windowSoftInputMode="adjustPan" in the manifest file for that particular activity.

For example :

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

Hope it will help :)

  • Related