मैं एक RecyclerView
एक ScrollView
अंदर लागू करने कर रहा हूँ। पूरे पृष्ठ पर केवल एक स्क्रॉलिंग व्यवहार करने के लिए मैं NonScrollRecyclerView
संस्करण लागू करता हूं। कार्यान्वयन इस प्रकार है:Android SDK में गैर स्क्रॉल RecyclerView स्क्रॉल मुद्दा 23
public class NonScrollRecyclerView extends RecyclerView {
public NonScrollRecyclerView(Context context) { super(context); }
public NonScrollRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollRecyclerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev){
if(ev.getAction() == MotionEvent.ACTION_MOVE)
return true;
return super.dispatchTouchEvent(ev);
}
}
एक बार मैं अपने निर्माण और लक्ष्य सेटिंग को अपडेट 23 SDK करने के लिए, मैं मुसीबत पृष्ठ NonScrollRecyclerView
शामिल स्क्रॉल है। विशिष्ट समस्या यह है कि जब तक मैं रीसाइक्लर व्यू भाग तक नहीं पहुंच जाता तब तक पेज स्क्रॉल ठीक हो जाता है और एक बार जब मैं इस दृश्य पर स्क्रॉल करता हूं तो मैं ऊपर या नीचे या तो स्क्रॉल करने में असमर्थ हूं। - @ लेआउट/आर वी
एक्सएमएल@layout/rv
recycler दृश्य
<ScrollView 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:background="@color/background_gray">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background_gray"
android:orientation="vertical">
<include
layout="@layout/row_mall_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cv_mall_header"
android:layout_marginTop="8dp"/>
<include
layout="@layout/row_mall_shops"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cv_mall_shops"
android:layout_marginTop="8dp"/>
<include
layout="@layout/row_mall_coupons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cv_mall_coupons"
android:layout_marginTop="8dp"/>
<include
layout="@layout/rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cv_mall_feeds"
android:layout_marginTop="8dp"/>
</LinearLayout>
</ScrollView>
एक्सएमएल शामिल हैं:
मैं एसडीके 22 के साथ और नीचे
मेरे एक्सएमएल इस समस्या का सामना DONOT इस प्रकार है
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_gray"
android:id="@+id/ll_mall_feeds">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:paddingTop="6dp"
android:paddingBottom="6dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_feedcount"
android:textColor="@color/semi_theme_blue"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="12dp"
android:layout_centerVertical="true" />
</RelativeLayout>
<com.project.ui.NonScrollRecyclerView
android:id="@+id/nrv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:listSelector="@android:color/transparent" />
</LinearLayout>
आप क्यों नहीं बस एक LinearLayout बजाय एक RecyclerView का उपयोग नहीं करते हैं? आप अनिवार्य रूप से एक RecyclerView को एक LinearLayout में बदल रहे हैं, लेकिन बहुत अधिक ओवरहेड के साथ। –
उपर्युक्त टिप्पणी के साथ सहमत हैं, बस रीसाइक्लर व्यू से छुटकारा पाएं, और, यदि आप इसे मानते हैं तो आप अब XML: // stackoverflow के बारे में पूछने के लिए नहीं जा रहे हैं।कॉम/प्रश्न/2 9 5 9 6014/क्यों-चाहिए-हम-उपयोग-एक्सएमएल-लेआउट – Nanoc
आप अपनी आवश्यकता के अनुसार अपना खुद का रैखिक लेआउट प्रबंधक बना सकते हैं ... इस लिंक को जांचें https://github.com/serso/android-linear- लेआउट प्रबंधक/ब्लॉब/मास्टर/lib/src/मुख्य/जावा/org/Solovyev/एंड्रॉयड/विचारों/एलएलएम/LinearLayoutManager.java –