久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何將 EditText 滾動到布局的最頂部?

How to scroll an EditText to the very top of the layout?(如何將 EditText 滾動到布局的最頂部?)
本文介紹了如何將 EditText 滾動到布局的最頂部?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

所以我在滾動視圖中有一些 ChipsInput 的布局,我只是希望這些在鍵盤被激活時轉到最頂部

So I have this layout with some ChipsInput inside a scrollview and I simply want these to go to the very top when the keyboard is activated

我嘗試將 windowSoftInputMode 更改為 adjustPan 等,但它并沒有讓它到達最頂端,只是沒有覆蓋它.

I've tried to change windowSoftInputMode to adjustPan and others but it does not make it to go to the very top, just doesn't cover it.

這是我的 xml 布局

Here's my xml layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background1"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">

<LinearLayout
    android:id="@+id/layoutImage"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:background="@color/colorPrimary"
    android:elevation="12dp"
    android:orientation="horizontal"
    android:padding="10dp"
    tools:targetApi="lollipop">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_margin="3dp"
        android:layout_weight="1"
        android:fontFamily="@font/quattrocento"
        android:gravity="left"
        android:text="@string/profile"
        android:textSize="20sp"
        android:textStyle="bold"
        android:textColor="@color/textColor1"
        tools:ignore="RtlHardcoded" />

    <ImageButton
        android:id="@+id/btUpdate"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="3"
        android:background="@color/colorPrimary"
        android:src="@drawable/arrow_right_icon" />

</LinearLayout>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="5dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="5dp"
        android:orientation="vertical"
        tools:targetApi="o">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:fontFamily="@font/quattrocento"
            android:gravity="center"
            android:text="@string/gallery"
            android:textSize="22sp"
            android:textStyle="bold"
            android:textColor="@color/textColor2"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:orientation="horizontal"
            android:padding="5dp"
            android:baselineAligned="false">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1">

                <ImageButton
                    android:id="@+id/close1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/icon_close"
                    android:background="@color/white"
                    android:layout_alignParentTop="true"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:elevation="7dp"
                    android:visibility="invisible"/>

                <ImageButton
                    android:id="@+id/add1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/icon_add"
                    android:background="@color/white"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:elevation="7dp"/>

                <ImageView
                    android:id="@+id/photo1"
                    android:layout_width="match_parent"
                    android:layout_height="115dp"
                    android:layout_marginHorizontal="5dp"
                    android:background="@drawable/rounded_rect_primary_dark"
                    android:elevation="5dp"
                    android:scaleType="fitXY"/>
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1">

                <ImageButton
                    android:id="@+id/close2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/icon_close"
                    android:background="@color/white"
                    android:layout_alignParentTop="true"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:elevation="7dp"
                    android:visibility="invisible"/>

                <ImageButton
                    android:id="@+id/add2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/icon_add"
                    android:background="@color/white"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:elevation="7dp"/>

                <ImageView
                    android:id="@+id/photo2"
                    android:layout_width="match_parent"
                    android:layout_height="115dp"
                    android:layout_marginHorizontal="5dp"
                    android:background="@drawable/rounded_rect_primary_dark"
                    android:elevation="5dp"
                    android:scaleType="fitXY" />
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1">

                <ImageButton
                    android:id="@+id/close3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/icon_close"
                    android:background="@color/white"
                    android:layout_alignParentTop="true"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:elevation="7dp"
                    android:visibility="invisible"/>

                <ImageButton
                    android:id="@+id/add3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/icon_add"
                    android:background="@color/white"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:elevation="7dp"/>

                <ImageView
                    android:id="@+id/photo3"
                    android:layout_width="match_parent"
                    android:layout_height="115dp"
                    android:layout_marginHorizontal="5dp"
                    android:background="@drawable/rounded_rect_primary_dark"
                    android:elevation="5dp"
                    android:scaleType="fitXY"/>
            </RelativeLayout>

        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginHorizontal="12dp"
            android:layout_marginVertical="5dp"
            android:background="@color/black" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginLeft="10dp"
            android:layout_marginStart="10dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/quattrocento"
                android:text="@string/about_me"
                android:textColor="@color/textColor2"
                android:textSize="20sp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:background="@color/white">

                <EditText
                    android:id="@+id/description"
                    android:layout_width="match_parent"
                    android:layout_height="70dp"
                    android:background="@color/white"
                    android:focusable="true"
                    android:maxLength="500"
                    android:inputType="text"
                    android:importantForAutofill="no"
                    android:autofillHints="no"
                    tools:ignore="LabelFor" />

                <TextView
                    android:id="@+id/caracCounter"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:fontFamily="@font/quattrocento"
                    android:text="500"
                    android:textColor="@color/black"
                    android:textSize="16sp"
                    android:layout_gravity="end" />
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="center"
            android:gravity="center"
            android:layout_marginLeft="10dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="10dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/quattrocento"
                android:text="@string/interest1"
                android:textColor="@color/textColor2"
                android:textSize="20sp"
                android:layout_gravity="center"
                android:gravity="center"/>

            <Spinner
                android:id="@+id/categories1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:background="@color/colorPrimary" />
        </LinearLayout>

        <com.pchmn.materialchips.ChipsInput
            android:id="@+id/chipsInput1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:background="@color/white"
            android:elevation="3dp"
            android:focusable="false"
            app:chip_deletable="true"
            app:chip_hasAvatarIcon="false"
            app:hint="#"
            app:chip_backgroundColor="@color/colorPrimary"
            app:chip_deleteIconColor="@color/black"
            app:chip_labelColor="@color/black"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="center"
            android:gravity="center"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginStart="10dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/quattrocento"
                android:text="@string/interest2"
                android:textColor="@color/textColor2"
                android:textSize="20sp"
                android:layout_gravity="center"
                android:gravity="center"/>

            <Spinner
                android:id="@+id/categories2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:background="@color/colorPrimary" />
        </LinearLayout>


        <com.pchmn.materialchips.ChipsInput
            android:id="@+id/chipsInput2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:background="@color/white"
            android:elevation="3dp"
            android:focusable="false"
            app:chip_deletable="true"
            app:chip_hasAvatarIcon="false"
            app:hint="#"
            app:chip_backgroundColor="@color/colorPrimary"
            app:chip_deleteIconColor="@color/black"
            app:chip_labelColor="@color/black" />

        <Button
            android:id="@+id/btLogout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_margin="25dp"
            android:background="@color/colorPrimary"
            android:elevation="12dp"
            android:fontFamily="@font/quattrocento"
            android:text="@string/logout"
            android:textSize="20sp"
            android:onClick="logout"
            tools:targetApi="lollipop"
            android:textColor="@color/black"/>
    </LinearLayout>
</ScrollView>

我只需要將它發送到布局的最頂部,這樣當用戶開始輸入時我的可過濾列表就會出現.

I simply need it to be sent to the very top of the layout so my filterable list will appear when the user start to type.

推薦答案

你可以使用CoordinatorLayout 作為你的根和 NestedScrollView 在里面.

You can use CoordinatorLayout as your root and NestedScrolView in it .

CoordinatorLayout 作為 root 對鍵盤做出反應,并使用 NestedScrollView 助手將您的布局滾動到手機頂部,您的 NestedScrollView 包含您的布局代碼.

CoordinatorLayout as root reacts to keyboard and scrolls your layout to the top of your phone with assistant of NestedScrollView which your NestedScrollView includes your layout code .

把問題放在透視圖中

CoordinaterLayout > NestedScrollView > yourLayout

改變你的布局 XMl 像下面的代碼

Change your layout XMl like code below

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:id="@+id/constraintLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/background1"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:orientation="vertical">
        <!-- rest of your layout xml code-->

    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

這篇關于如何將 EditText 滾動到布局的最頂部?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 在线成人www免费观看视频 | 精品国产18久久久久久二百 | 在线视频一区二区三区 | 久草综合在线 | 日本不卡视频在线播放 | 国产最新网址 | 欧美日韩电影免费观看 | 国产人成在线观看 | 91精品观看 | 午夜伊人| 日韩在线观看 | 色婷婷一区二区三区四区 | 99精品一区二区三区 | 婷婷精品 | 国产精久久久 | 色视频在线播放 | 女朋友的闺蜜3韩国三级 | 亚洲欧洲日本国产 | 久久伊人精品一区二区三区 | 中文字幕在线观看一区 | 国产精品久久久久久久午夜片 | 亚洲免费在线观看 | 久在线 | 天天玩天天操天天干 | 自拍偷拍第一页 | 免费视频二区 | 在线看片国产 | 欧美在线观看黄色 | 嫩草最新网址 | 亚洲视频国产 | 在线视频亚洲 | 国产精品成人在线播放 | 羞羞视频免费在线观看 | 中文字幕在线网 | 黑人巨大精品欧美一区二区一视频 | 成人国产精品色哟哟 | 久久91 | 日本不卡一区二区三区在线观看 | av在线播放免费 | 天天草天天射 | 成年人在线观看视频 |