0

I have an activity that contains a scrollview and that has a two child but when the activity loads it doesn't show the top part and start from the top of gridview !

<RelativeLayout 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/activityBackground"
tools:context="com.test.app.fragment.HomeFragment">

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="60dp"
            android:background="@color/ColorPrimaryDark"/>

        <com.test.app.util.ExpandableHeightGridView
            android:id="@+id/homeNormalGridView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:numColumns="2"
            android:padding="5dp"
            android:stretchMode="columnWidth" />
        </LinearLayout>


</ScrollView>

<fr.castorflex.android.circularprogressbar.CircularProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/homeProgress"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:indeterminate="true"
    app:cpb_color="@color/ColorPrimary"
    app:cpb_max_sweep_angle="300"
    app:cpb_min_sweep_angle="10"
    app:cpb_rotation_speed="1.0"
    app:cpb_stroke_width="4dp"
    app:cpb_sweep_speed="1.0" />
</RelativeLayout>

as you see i have GridView and RelativeLayout as a child of scrollview but i haven't any idea why the relativeLayout is going to hide !

user2549089
  • 281
  • 2
  • 4
  • 14

1 Answers1

0

I don't see anything in your layout that would appear above your custom GridView. In addition, you're not setting any properties on the Relative layout to position the children.

Normally when something like the ExpandableHeightGridView is used it is used to allow embedding the grid view inside a scroll view, disabling the grid views scroll. This allows other components to scroll along with the GridView. I've used it on projects to have a synchronized scroller and a quick return scroll. In those causes, there is usually a so called anchor view above or below the grid view to allow some other view to be attached there.

    <View
        android:id="@+id/anchor"
        android:layout_width="fill_parent"
        android:layout_height="0dp"/>

In the custom code for the ExpandableHeightGridView you would attach another view as the anchor view, maybe your progress bar, and it would appear in place of the anchor. The java code for the custom gridview is also responsible for dynamically positioning the anchor.

As stated, there are drawbacks to disabling the scroll of the gridView, it removes all the optimizations and just becomes a large table. You may see performance issues or high memory usage if there are lots of items in the table.

Gary Bak
  • 4,746
  • 4
  • 22
  • 39