I found the solution in SOF for using gridview
with expanded height inside scrollview
from this link. But I have a problem when the gridview
items are dynamic
.My problem is,
When the items are less, it works fine. If the number of items increases then the Gridview last row or some rows are not visible. And also I am getting some empty space above the first row.
This is my gridview,
<com.example.xyz.myapp.ExpandableHeightGridView
android:id="@+id/favor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:clipChildren="false"
android:fitsSystemWindows="true"
/>
Expandable height gridview
code is code is,
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (isExpanded()) {
int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
Can Anyone help me. Thanks in advance.