Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using ScrollView for scrolling my layout.But not working in Fragment class when keyboard is open. I am novice with Fragments.

Here is my XML Code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/settingLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/splash_bg" >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <ImageView
            android:id="@+id/tree_iv_userSettings"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@drawable/tree_transparent" />
        <ScrollView
            android:id="@+id/sv_rl_user_settings"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:isScrollContainer="true" >

            <RelativeLayout
                android:id="@+id/main_rl_user_settings"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center" >

                <ImageView
                    android:id="@+id/image1"
                    android:layout_width="90dp"
                    android:layout_height="110dp"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="30dp"
                    android:src="@drawable/frame_large" />

                <TextView
                    android:id="@+id/changepassword"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/image1"
                    android:layout_marginLeft="20dp"
                    android:background="@android:color/transparent"
                    android:hint="CHANGE PASSWORD"
                    android:singleLine="true"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@android:color/black"
                    android:textColorHint="@android:color/black" />

                <EditText
                    android:id="@+id/editname"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/changepassword"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="15dp"
                    android:background="@android:color/transparent"
                    android:hint="EDIT NAME"
                    android:maxLength="20"
                    android:singleLine="true"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColorHint="@android:color/black" />

                <EditText
                    android:id="@+id/editphoneno"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/editname"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="15dp"
                    android:background="@android:color/transparent"
                    android:hint="EDIT PHONE NUMBER"
                    android:maxLength="15"
                    android:numeric="integer"
                    android:singleLine="true"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColorHint="@android:color/black" />

                <TextView
                    android:id="@+id/edittype"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/editphoneno"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="15dp"
                    android:background="@android:color/transparent"
                    android:singleLine="true"
                    android:text="EDIT TYPE"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@android:color/black" />

                <TextView
                    android:id="@+id/notification"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/edittype"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="15dp"
                    android:background="@android:color/transparent"
                    android:singleLine="true"
                    android:text="NOTIFICATION"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@android:color/black" />

                <Button
                    android:id="@+id/togNot"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_above="@+id/save"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="20dp"
                    android:background="@drawable/on_button" />

                <TextView
                    android:id="@+id/save"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/notification"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="30dp"
                    android:background="@android:color/transparent"
                    android:text="SAVE "
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@android:color/black"
                    android:textSize="40dp" />

                <ProgressBar
                    android:id="@+id/progressBar1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignBottom="@+id/image1"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="27dp" />
            </RelativeLayout>
        </ScrollView>

        <RelativeLayout
            android:id="@+id/bottomRelay"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_margin="7.5dp"
            android:background="@android:color/transparent"
            android:visibility="gone" >

            <TextView
                android:id="@+id/Upload"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:background="#ededed"
                android:gravity="center"
                android:text="Upload Photo"
                android:textColor="#8F8F8F"
                android:textSize="20dp"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/border1"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@id/Upload"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:background="#939393" />

            <TextView
                android:id="@+id/choose_existing"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_below="@+id/border1"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="1dp"
                android:background="#ededed"
                android:gravity="center"
                android:text="Library"
                android:textColor="#007AFF"
                android:textSize="20dp"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/border2"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@id/choose_existing"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:background="#939393" />

            <TextView
                android:id="@+id/Camera"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_below="@+id/border2"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="1dp"
                android:background="#ededed"
                android:gravity="center"
                android:text="Camera"
                android:textColor="#007AFF"
                android:textSize="20dp"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/border3"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@id/Camera"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:background="#939393" />

            <TextView
                android:id="@+id/cancel"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_below="@+id/border3"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="20dp"
                android:background="#ededed"
                android:gravity="center"
                android:text="Cancel"
                android:textColor="#007AFF"
                android:textSize="20dp"
                android:textStyle="bold" />
        </RelativeLayout>

        <ImageView
            android:id="@+id/dropimg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/drop_down"
            android:visibility="invisible" />
    </RelativeLayout>

</RelativeLayout>

Manifest code of that Activity:

android:name="com.treeapp.header.Header"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:theme="@android:style/Theme.NoTitleBar"
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
136 views
Welcome To Ask or Share your Answers For Others

1 Answer

I am sugesting you to use LinearLayout instead of relative layout with vertical orientation layout in which you are using scroll and to hide your keyboard you can use the below code when you scroll the view just use

ScrollView anyname;
anyname =(ScrollView)rootView.findViewById(R.id.sv_rl_user_settings);
anyname.setparentView.setOnTouchListener(this);



@Override
        public boolean onTouch(View v, MotionEvent event) {
            InputMethodManager imm = (InputMethodManager) getactivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getactivity().getWindow().getCurrentFocus().getWindowToken(), 0);
            return false;

        }
in your fragment java file i hope it will work

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...