Android6.0 above about Recyclerview is not the whole problem

Source: Internet
Author: User

Android6.0 above about Recyclerview is not the whole problem needs description

Adaptation when found Android 6.0 above, Recyclerview display is not complete, the following is no problem.
This time to view the layout file, you can see that Recyclerview is nested in the ScrollView.

<scrollview android:layout_width= "match_parent" android:layout_height= "wrap_content" > <andro Id.support.v7.widget.RecyclerView android:layout_width= "match_parent" android:layout_height= "match_p Arent "android:overscrollmode=" Never "android:paddingleft=" 16DP "android:paddingright=" 16 DP "/> </ScrollView>
Workaround the first method of solution

On Recyclerview, add a property android:descendantfocusability= "Blocksdescendants" When you nest a layer of relativelayout (when a view gets focus, ViewGroup overrides the subclass control and takes the focus directly) to solve the problem of nested lag.

Note that it is not possible to set up the use of relativelayout only, using other commonly used layout controls such as Framelayout, LinearLayout, etc. Test.

Code
<scrollview android:layout_width= "match_parent" android:layout_height= "wrap_content" > <Relat Ivelayout android:layout_width= "match_parent" android:layout_height= "Match_parent" Androi d:descendantfocusability= "Blocksdescendants" > <android.support.v7.widget.recyclerview Android Oid:layout_width= "Match_parent" android:layout_height= "Match_parent" android:overscrollmode= "Never" android:paddingleft= "16DP" android:paddingright= "16DP"/> </relativelay Out> </ScrollView>
The second method of solution

Replace ScrollView with Android.support.v4.widget.NestedScrollView and set recyclerview.setnestedscrollingenabled (false) in code (Sets whether nested slides are allowed). You can fill in a hole where the item is not full, and you can fill in the hole where the slip is stuck.

Code
<android.support.v4.widget.nestedscrollview android:layout_width= "match_parent" android:layout_height= "WR            Ap_content "> <android.support.v7.widget.recyclerview android:layout_width=" match_parent "            android:layout_height= "Match_parent" android:overscrollmode= "Never" android:paddingleft= "16DP" android:paddingright= "16DP"/> </android.support.v4.widget.NestedScrollView>
recyclerView.setNestedScrollingEnabled(false);
Summarize

In comparison, individuals feel that the second solution is better, the first method layout nesting, there is always a desire to optimize the impulse, so think the second solution is better.

Android6.0 above about Recyclerview is not the whole problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.