0

I have a problem with scrolling grid view. I want to show all pictures that existed on sd card in just one grid view. My main code like the below code:

public class FragmentImageFolder extends Fragment {
Toolbar toolbar;
CollapsingToolbarLayout collapsingToolbarLayoutAndroid;
CoordinatorLayout rootLayoutAndroid;
GridView gridView;
Context context;
ArrayList arrayList;
private Database database;
private TypeFaces typeFaces;

public static String[] gridViewImages ;

 private FileAccess fileAccess;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
    final View rootView= inflater.inflate(R.layout.fragment_image_folder, container, false);
    typeFaces=new TypeFaces(getContext());

    database=new Database(getContext());
    fileAccess=new FileAccess();

   database.open();
    int count=fileAccess.gotoimage().length;

    gridViewImages=new String[count+1];
    File[] file=fileAccess.gotoimage();
    for(int i=0;i<count;i++)
    {
        gridViewImages[i]=file[i].getAbsolutePath();
    }
    database.close();
    gridView = (GridView) rootView.findViewById(R.id.grid);

    gridView.setAdapter(new GridViewAdapterFolder(getContext(),gridViewImages));


    return rootView;
}

My activity is coming below:

<LinearLayout android:id="@+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"

xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/windows_backgound_gridview"
>

<GridView
            android:id="@+id/grid"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:columnWidth="100dp"
            android:gravity="center"
            android:listSelector="#00000000"
            android:numColumns="3"
            android:stretchMode="columnWidth"
    android:nestedScrollingEnabled="true"
    android:scrollbars="vertical"

    />

    </LinearLayout>

My pictures in grid view cant be scrolled I should mention that my gird view is in one fragment.

1 Answers1

0

Try changing layout_height in linear layout to wrap_content .

If it still does not scroll , change your gridview with custom gridview as this:

https://stackoverflow.com/a/24186541/5879376

Community
  • 1
  • 1
Rishabh Maurya
  • 1,448
  • 3
  • 22
  • 40