0

我有一个片段,其中我有 ListView,它在每一行和页脚视图中都有 EditText,当我设置android:windowSoftInputMode="adjustPan"时,所有控件都在 ScrollView 中,而不是在软键盘打开时滚动我的页脚视图表单并向上推我活动的标题,当我尝试使用android:windowSoftInputMode="adjustResize"它滚动页脚视图表单但是当任何项目打开并失去 EditText 焦点但我的标题没有向上移动时它会自动滚动我的列表视图。对不起,我不善于解释,但我希望任何人都明白我想解释的内容。实际上,我想将滚动视图滚动到页脚视图中的特定布局,以便我面对所有这些问题,任何人都可以帮助我吗?谢谢你

在此处输入图像描述

这是我的片段 xml 文件

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

这是我的listview的footerView xml

<?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>
4

1 回答 1

0

您可以尝试从页脚中删除滚动视图并将其添加到片段中,然后您可以使用 NonScrollableListView 而不是 ListView。

有关如何使用 NonScrollableListView 的更多参考,请使用:

ScrollView 内不可滚动的 ListView

PS:希望您在 ListView 的适配器中使用 ViewHolders。

干杯!

于 2017-04-07T06:16:41.470 回答