简体   繁体   中英

Why edittext is hide behinde softkeyboard

i have a image out of ScrollView and several edit text in one scroll view but when click on one EditText and open keyboard size of that image view is changed i dont want to change size of that for this i add android:windowSoftInputMode="adjustResize|adjustPan|stateVisible" to my activity in manifests but now last EditText 's is hide behind of keyboard when keyboard is open and scroll view not scrolled to last . xml : `

<include
    android:id="@+id/toolbar"
    layout="@layout/toolbar_without_elevation" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.25"
    android:background="@color/primary_color"
    android:gravity="center"
    android:orientation="horizontal">

    <TextView
        android:layout_width="@dimen/size_0_dp"
        android:layout_height="match_parent"
        android:layout_weight="0.3" />

    <com.balysv.materialripple.MaterialRippleLayout
        android:id="@+id/rippleChangeProfileImage"
        style="@style/ImageViewRipple"
        android:layout_width="@dimen/size_0_dp"
        android:layout_height="match_parent"
        android:layout_weight="0.4"
        android:gravity="center">

        <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/imgProfile"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_gravity="center"
            android:layout_margin="@dimen/size_8_dp"
            android:background="@drawable/ic_add_a_photo_white_48dp"
            android:onClick="changeContactPhoto"
            app:civ_border_color="#ffffff"
            app:civ_border_width="2dp" />
    </com.balysv.materialripple.MaterialRippleLayout>

    <TextView
        android:layout_width="@dimen/size_0_dp"
        android:layout_height="match_parent"
        android:layout_weight="0.3" />
</LinearLayout>

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.75"
    android:fillViewport="true"
    android:isScrollContainer="false"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <!--android:layout_weight="1"-->


        <LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/size_10_dp"
            android:gravity="center"
            android:orientation="vertical">
            <!--android:layout_marginTop="@dimen/size_10_dp"-->

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/linearName"
                style="@style/ProfileLinearLayout"
                android:layout_marginBottom="@dimen/size_5_dp">

                <com.rengwuxian.materialedittext.MaterialEditText
                    android:id="@+id/edtName"
                    style="@style/profileDialogEditText"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/size_16_dp"
                    android:layout_marginRight="@dimen/size_16_dp"
                    android:layout_weight="1"
                    android:gravity="right"
                    android:paddingRight="@dimen/size_10_dp"
                    android:singleLine="true"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@color/Profile_text_color"
                    android:textSize="@dimen/size_12_sp"
                    app:met_floatingLabel="normal"
                    android:windowSoftInputMode="adjustResize" />

                <ImageView
                    android:id="@+id/imgName"
                    android:layout_width="32dp"
                    android:layout_height="32dp"
                    android:layout_marginRight="16dp"
                    android:layout_marginTop="@dimen/size_15_dp"
                    android:src="@drawable/ic_person_outline_white_24dp" />
            </LinearLayout>

            <ImageView
                android:id="@+id/imageView13"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/size_5_dp"
                android:src="@drawable/item_separator_as_line" />

    //several EditText Like This

        </LinearLayout>

`

try to remove your weight from your master linear layout it should works ; and set your screen width or height to your linearLayout

Add this to your <activity> :

android:windowSoftInputMode="adjustPan" 

or:

android:windowSoftInputMode="adjustResize" 

Like this:

<activity
    android:name="com.my.MainActivity"
    android:screenOrientation="portrait"
    android:label="@string/title_activity_main"
    android:windowSoftInputMode="stateVisible|adjustResize" >
</activity>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM