This article illustrates the ScrollView nested GridView method of Android programming development. Share to everyone for your reference, specific as follows:
A few days ago in the development of the need to scrollview nested gridview, because these two controls are brought by the scroll bar, when they encounter together will be a problem, that the GridView will not show the whole, in order to solve this problem to find more than n data, A Google official reply unexpectedly is the GridView does not need to scrollview, that bullish, ah, but I have to use the swollen do it?! and continue to check, God horse rewrite the control rewrite class, that code a lump of wood has!!! Finally, the inspiration is finally realized by someone with a very vague hint.
The first is the layout
<ScrollView> ...
<LinearLayout>
</LinearLayout> ...
</ScrollView>
All we have to do is customize a GridView control and insert it into the middle of the linearlayout.
public class MyGridView extends gridview{
the public mygridview (context context, AttributeSet Attrs) {
super ( context, attrs);
}
Public MyGridView {
super (context);
}
Public MyGridView (context, AttributeSet attrs, int defstyle) {
Super (context, attrs, Defstyle);
}
@Override public
void onmeasure (int widthmeasurespec, int heightmeasurespec) {
int expandspec = Measurespec.makemeasurespec (Integer.max_value >> 2,
measurespec.at_most);
Super.onmeasure (Widthmeasurespec, Expandspec);
}
This custom control only rewrites the GridView Onmeasure method so that it does not appear scrollbars, ScrollView nesting listview is the same truth, no longer tired of
I hope this article will help you with the Android program.