Android:RecyclerView不兼容

杰克

这是我的XML代码,在Android 5、6、7及更高版本上运行良好。我看到它在5以下的Android上无法滚动。我不知道此问题与RecyclerView或设备内存的焦点有关

例如在Honor 4C上它不会滚动,而其他一些手机也像android 4.2.2上的Huawei。

似乎应用程序或智能手机没有崩溃,只是没有滚动。

这是我的布局XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/white"
    tools:context="ir.example.app.Activity.BuyInternetActivity">

    <include layout="@layout/actionbar"/>

    <ScrollView
        android:id="@+id/parent_internet"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="@dimen/_5sdp"
            android:layout_margin="@dimen/_10sdp">

            <ir.exapmle.app.Widgets.Txtview
                android:id="@+id/lbl_buychargecoe_1"
                android:layout_gravity="center"
                android:gravity="bottom|center"
                android:layout_weight="0.2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="شماره موبایل مورد نظر را وارد کنید:"
                android:textColor="@android:color/black"
                android:textSize="@dimen/_13sdp" />

            <LinearLayout
                android:layout_marginTop="@dimen/_3sdp"
                android:weightSum="1"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:layout_marginRight="@dimen/_10sdp"
                    android:layout_marginLeft="@dimen/_10sdp"
                    android:gravity="top"
                    android:background="@drawable/edittext"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/_40sdp">

                    <ImageView
                        android:id="@+id/img_contact_internet"
                        android:layout_marginStart="@dimen/_20sdp"
                        android:layout_gravity="center"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_phonebook_selected"/>


                    <ir.exapmle.app.Widgets.Edtview
                        android:background="@android:color/transparent"
                        android:focusableInTouchMode="true"
                        android:layout_weight="0.8"
                        android:layout_width="0dp"
                        android:layout_height="@dimen/_35sdp"
                        android:layout_gravity="center"
                        android:layout_marginRight="10dp"
                        android:id="@+id/edt_buynet_phonenumber"
                        android:gravity="center"
                        android:paddingTop="5dp"
                        android:maxLength="24"
                        android:paddingBottom="5dp"
                        android:paddingEnd="5dp"
                        android:paddingStart="13dp"
                        android:hint="09 - - - - - - - - -"
                        android:inputType="number"
                        android:textSize="@dimen/_12sdp"/>
                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_marginBottom="@dimen/_10sdp"
                android:weightSum="1"
                android:id="@+id/lyt_ownNumber"
                android:gravity="right"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <Switch
                    android:theme="@style/SwitchCompatTheme"
                    android:textColor="@color/colorKipo"
                    android:id="@+id/switch_internetOwnNumber"
                    android:layout_weight="0.1"
                    android:layout_marginTop="@dimen/_10sdp"
                    android:layout_width="@dimen/_40sdp"
                    android:layout_height="@dimen/_30sdp" />
                <ir.exapmle.app.Widgets.Txtview
                    android:layout_weight="0.1"
                    android:layout_marginTop="@dimen/_10sdp"
                    android:layout_marginRight="@dimen/_10sdp"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="@dimen/_11sdp"
                    android:text="شماره خودم"/>
            </LinearLayout>

            <ir.exapmle.app.Widgets.Txtview
                android:id="@+id/txt_operator"
                android:layout_gravity="center"
                android:gravity="bottom|center"
                android:layout_weight="0.2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="اپراتور موردنظر را انتخاب کنید:"
                android:textColor="@android:color/black"
                android:textSize="@dimen/_13sdp"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp"/>

            <LinearLayout
                android:weightSum="1"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <ImageView
                    android:id="@+id/img_buycharge_code_mci"
                    android:padding="@dimen/_3sdp"
                    android:layout_weight="0.3"
                    android:layout_width="@dimen/_64sdp"
                    android:layout_height="@dimen/_64sdp"
                    android:src="@drawable/ic_pin_mci_unselected" />

                <ImageView
                    android:id="@+id/img_buycharge_code_irancel"
                    android:layout_weight="0.3"
                    android:padding="@dimen/_3sdp"
                    android:layout_width="@dimen/_64sdp"
                    android:layout_height="@dimen/_64sdp"
                    android:src="@drawable/ic_pin_irancell_unselected"/>


                <ImageView
                    android:id="@+id/img_buycharge_code_rightel"
                    android:layout_weight="0.3"
                    android:padding="@dimen/_3sdp"
                    android:layout_width="@dimen/_60sdp"
                    android:layout_height="@dimen/_64sdp"
                    android:src="@drawable/ic_pin_rightel_unselected"/>

            </LinearLayout>

            <LinearLayout
                android:visibility="gone"
                android:orientation="vertical"
                android:id="@+id/lyt_packages"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:layout_marginTop="@dimen/_10sdp"
                    android:layout_marginBottom="@dimen/_10sdp"
                    android:gravity="top"
                    android:weightSum="1"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <RelativeLayout
                        android:layout_weight="0.5"
                        android:gravity="center"
                        android:weightSum="1"
                        android:background="@drawable/card_border"
                        android:orientation="horizontal"
                        android:layout_width="0dp"
                        android:layout_height="match_parent">
                        <Spinner
                            android:layout_margin="@dimen/_5sdp"
                            android:background="@drawable/spinner_border"
                            android:id="@+id/spin_terms"

                            android:layout_width="match_parent"
                            android:layout_height="@dimen/_30sdp">
                        </Spinner>
                        <ImageView
                            android:layout_width="@dimen/_24sdp"
                            android:layout_height="@dimen/_24sdp"
                            android:layout_alignEnd="@+id/spin_terms"
                            android:layout_centerVertical="true"
                            android:layout_marginEnd="12dp"
                            android:padding="@dimen/_5sdp"
                            android:src="@drawable/ic_arrow_down" />
                    </RelativeLayout>

                    <ir.exapmle.app.Widgets.Txtview
                        android:layout_weight="0.5"
                        android:gravity="center"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:textSize="@dimen/_10sdp"
                        android:text="مدت زمان بسته را انتخاب کنید :"/>

                </LinearLayout>


                <ir.exapmle.app.Widgets.Txtview
                    android:id="@+id/txt_selectedPackage"
                    android:gravity="center"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:textColor="#000"
                    android:textSize="@dimen/_10sdp"
                    android:text="هنوز بسته ای را انتخاب نکرده اید"/>

                <LinearLayout
                    android:id="@+id/lyt_packageContents"
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <LinearLayout
                        android:padding="@dimen/_5sdp"
                        android:weightSum="1"
                        android:orientation="horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <ir.exapmle.app.Widgets.Txtview
                            android:gravity="center"
                            android:layout_weight="0.33"
                            android:layout_width="0dp"
                            android:textSize="@dimen/_11sdp"
                            android:layout_height="wrap_content"
                            android:text="مبلغ"/>

                        <ir.exapmle.app.Widgets.Txtview
                            android:gravity="center"
                            android:layout_marginLeft="@dimen/_4sdp"
                            android:layout_weight="0.34"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:textSize="@dimen/_11sdp"

                            android:text="توضیحات"/>

                        <ir.exapmle.app.Widgets.Txtview
                            android:layout_marginRight="@dimen/_5sdp"
                            android:gravity="center"
                            android:layout_weight="0.33"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:textSize="@dimen/_11sdp"

                            android:text="حجم"/>
                    </LinearLayout>
                    <LinearLayout
                        android:layout_marginLeft="@dimen/_15sdp"
                        android:layout_marginRight="@dimen/_15sdp"
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:background="#ccc" />
                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/recycler_internets"
                        android:padding="@dimen/_5sdp"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/_110sdp">
                    </android.support.v7.widget.RecyclerView>
                </LinearLayout>
            </LinearLayout>



    </ScrollView>

</LinearLayout>

谢谢你的帮助 :)

MJ

在布局中只使用NestedScrollView而不是ScrollView

<android.support.v4.widget.NestedScrollView
android:id="@+id/parent_internet"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/_5sdp"
android:layout_margin="@dimen/_10sdp">

<ir.exapmle.app.Widgets.Txtview
android:id="@+id/lbl_buychargecoe_1"
android:layout_gravity="center"
android:gravity="bottom|center"
android:layout_weight="0.2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="شماره موبایل مورد نظر را وارد کنید:"
android:textColor="@android:color/black"
android:textSize="@dimen/_13sdp" />

<ir.exapmle.app.Widgets.Txtview
android:layout_marginRight="@dimen/_5sdp"
android:gravity="center"
android:layout_weight="0.33"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="@dimen/_11sdp"

android:text="حجم"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<LinearLayout
android:layout_marginLeft="@dimen/_15sdp"
android:layout_marginRight="@dimen/_15sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ccc" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_internets"
android:padding="@dimen/_5sdp"
android:layout_width="match_parent"
android:layout_height="@dimen/_110sdp">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章