简体   繁体   中英

Listview with EditText in each row , Scrollview inside FooterView of listview , adjustResize and adjustPan all working toghter

I have an one fragment in which I have ListView which has EditText in each row and inside footerview all controls are inside ScrollView when I set android:windowSoftInputMode="adjustPan" than it is not scroll my footerview form when softkeyboard open and also push up my header of activity and when I am trying to use android:windowSoftInputMode="adjustResize" it scroll footer view form but it auto scrolling my listview when any item open and lost EditText focus but my header is not move up. Sorry I am not good in explaining but I hope any one undersatand what i want to explain. Actually i want to scroll scrollview to specific layout in footerview so that I face all these problems any one can help me ? Thank You

在此处输入图片说明

Here is my fragment xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/application_background">
    <ListView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:id="@+id/card_list"
        android:fadingEdgeLength="0dp"
        android:scrollbars="none"
        android:headerDividersEnabled="false"
        android:descendantFocusability="afterDescendants"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:listSelector="@android:color/transparent"
        android:footerDividersEnabled="false"
        android:transcriptMode="alwaysScroll" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:orientation="horizontal"
        android:id="@+id/ll_footer"
        android:gravity="center"
        android:background="@color/colorIndicatorFill">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Pay 250"
            android:textColor="@color/white"
            android:id="@+id/txt_pay"
            android:gravity="center"
            android:textSize="@dimen/fontsize_txtview_18" />
    </LinearLayout>
</LinearLayout>

Here is my footerView xml of listview

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fillViewport="true"
    android:isScrollContainer="true"
    android:id="@+id/scrollView">
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/ll_footer_card"
        android:padding="10dp">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:orientation="horizontal"
            android:id="@+id/rl_or">
            <TextView
                android:id="@+id/txt_or"
                android:textSize="@dimen/fontsize_txtview_16"
                android:singleLine="true"
                android:text="@string/or"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@color/colorActiveIndicator"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_1"
                android:layout_centerVertical="true"
                android:paddingLeft="@dimen/size_10"
                android:layout_toLeftOf="@id/txt_or"
                android:background="@color/gray_light" />
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_1"
                android:layout_centerVertical="true"
                android:paddingRight="@dimen/size_10"
                android:layout_toRightOf="@id/txt_or"
                android:background="@color/gray_light" />
        </RelativeLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:id="@+id/ll_choose_other_card">
            <TextView
                android:layout_width="0dp"
                android:layout_weight="0.9"
                android:layout_height="wrap_content"
                android:text="@string/choose_other_card"
                android:id="@+id/txt_add_new_card"
                android:textSize="@dimen/fontsize_txtview_16"
                android:textColor="@color/colorActiveIndicator"/>
            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/radio_add_new_crad"
                style="@style/RadioButton" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/ll_card_detail_form">
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_10"/>
            <LinearLayout
                android:layout_width="wrap_content"
                android:gravity="center"
                android:layout_gravity="center"
                android:id="@+id/ll_scan_card"
                android:layout_height="wrap_content"
                android:background="@drawable/round_corner_light_green">
                <ImageView
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:src="@drawable/cards"
                    android:id="@+id/iv_card"
                    android:scaleType="centerInside"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/scan_card"
                    android:textSize="@dimen/fontsize_txtview_16"
                    android:textColor="@color/color_white"
                    android:id="@+id/txt_scan_card"/>
            </LinearLayout>
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_10"/>
            <View
                android:layout_width="@dimen/size_300"
                android:layout_gravity="center"
                style="@style/DividerBottomLine"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_10"/>
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/edt_card_number"
                android:hint="@string/hint_card_number"
                android:singleLine="true"
                android:digits=" 1234567890"
                android:inputType="number"
                android:maxLength="23"
                android:textColor="@color/text_color"
                android:textColorHint="@color/hint_color"
                android:textSize="@dimen/fontsize_edttext"
                android:background="@drawable/edt_background" />
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_10"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/edt_expiry"
                android:hint="@string/hint_expiry"
                android:singleLine="true"
                android:inputType="none"
                android:imeOptions="actionNext"
                android:textColor="@color/text_color"
                android:textColorHint="@color/hint_color"
                android:textSize="@dimen/fontsize_edttext"
                android:background="@drawable/edt_background" />
            <net.cachapa.expandablelayout.ExpandableLayout
                android:id="@+id/expandable_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:el_duration="500"
                app:el_expanded="false">
                <LinearLayout  android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:id="@+id/ll_datePicker"
                    android:animateLayoutChanges="true"
                    android:orientation="vertical">
                    <LinearLayout
                        android:id="@+id/main_layout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/application_background"
                        android:orientation="vertical" >
                        <LinearLayout
                            android:id="@+id/layout_choose"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:orientation="horizontal" >
                            <kankan.wheel.widget.WheelView
                                android:id="@+id/wheel_month"
                                android:layout_width="0dp"
                                android:layout_weight="0.5"
                                android:background="@color/white"
                                android:layout_height="wrap_content" />
                            <kankan.wheel.widget.WheelView
                                android:id="@+id/wheel_year"
                                android:layout_width="0dp"
                                android:layout_weight="0.5"
                                android:background="@color/white"
                                android:layout_height="wrap_content" />
                        </LinearLayout>
                        <widget.RippleView
                            android:id="@+id/ripple_confirm"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:gravity="center"
                            app:rv_centered="true"
                            app:rv_color="@color/white"
                            app:rv_type="simpleRipple" >
                            <TextView
                                android:id="@+id/txt_confirm"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:gravity="center"
                                android:background="@drawable/round_corner_light_green"
                                android:text="@string/btn_Done"
                                android:textColor="@color/color_white"
                                android:textSize="@dimen/fontsize_txtview_18" />
                        </widget.RippleView>
                    </LinearLayout>

                </LinearLayout>
            </net.cachapa.expandablelayout.ExpandableLayout>
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_10"/>
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/edt_cvv"
                android:hint="@string/hint_cvv"
                android:singleLine="true"
                android:imeOptions="actionNext"
                android:inputType="number"
                android:maxLength="4"
                android:textColor="@color/text_color"
                android:textColorHint="@color/hint_color"
                android:textSize="@dimen/fontsize_edttext"
                android:background="@drawable/edt_background" />
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_10"/>
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/edt_name_on_card"
                android:hint="@string/hint_name_on_card"
                android:singleLine="true"
                android:maxLength="100"
                android:textColor="@color/text_color"
                android:textColorHint="@color/hint_color"
                android:textSize="@dimen/fontsize_edttext"
                android:imeOptions="actionDone"
                android:background="@drawable/edt_background" />
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_10"/>
            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/chk_save_card"
                android:textColor="@color/text_color"
                style="@style/Checkbox"
                android:textSize="@dimen/fontsize_edttext"
                android:text="@string/save_card" />
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/size_10"/>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

You can try by removing the scrollview from the footer and adding it to the fragment, and then you can use a NonScrollableListView instead of ListView.

For more reference on how to use a NonScrollableListView use this:

Non-scrollable ListView inside ScrollView

PS: Hope you are using ViewHolders inside your adapter for the ListView.

Cheers!

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