androidandroid-layoutnativescriptandroid-scrollviewandroid-keypad

Android Keyboard hides TextView Element NativeScript


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" 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>

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>

Solution

  • 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 :)