Android resolve RecyclerView the item display incomplete program

Recent projects in order to determine the realization of the page. ScrollView need to use nested RecyclerView, when the number of item RecyclerView size is big, there will be only part of the data item is displayed, and no user will be shown the number of items checked all this time we need to do something to deal with.

Here's two solutions:

1, replace the use of new control NestedScrollView 5.0 ScrollView.
NestedScrollView supports nested slide, both to fill item display incomplete pit, and you can fill in a nested slide Caton pit. Do not understand the wave of children's shoes can go to learn, do not detail here illustrates.

Usage:
(1), the layout file will replace ScrollView "android.support.v4.widget.NestedScrollView."
(2), using code provided recyclerView.setNestedScrollingEnabled (false) to.

2, one nested RelativeLayout RecyclerView outside, and then add the attribute android: descendantFocusability = "blocksDescendants".

Usage reference:

<RelativeLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:descendantFocusability="blocksDescendants">
     
        <android.support.v7.widget.RecyclerView
             android:id="@+id/recyclerView"
             android:layout_width="match_parent"
             android:layout_height="match_parent"  
             android:overScrollMode="never"/>
             
</RelativeLayout>

Having said that let us familiarize ourselves with android: the role of descendantFocusability = "blocksDescendants" attribute:

The meaning of the attribute is: a view acquired when the focal point, the relationship between definitions and its child controls ViewGroup.

It is a total of three property values, which are:

beforeDescendants: viewGroup priority subclass controls and gain focus;

afterDescendants: viewGroup only when the child does not need to get the focus of the class for controls before going to get the focus;

blocksDescendants: viewGroup will cover subclass controls and direct access to the focal point.

Two programs to introduce over here.


 

The following is a personal public number (longxuanzhigu), after the release of the article will be synchronized to the public number, to facilitate the exchange of knowledge and learning Android share personal hobby articles, there is a problem you can shout oh:

Guess you like

Origin www.cnblogs.com/showly/p/11229795.html
Recommended