0

I have a GridView that can contain NxM Custom Items (actually memes)

The problem i'm facing is, when i try to save a bitmap from those images, it gets cropped to the image is rendered on screen, because not visible images or portions of images are null space.

(if there's a way to actually capture those images without resizing the grid please let me know).

so what i want to do right now is to resize the grid to fit available screen height.

here's part of my Main Layout:

    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:id="@+id/rlMemeHolder"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:layout_below="@id/ads_banner"
    android:layout_above="@+id/relativeLayout">
    <GridView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:layout_marginStart="25dp"
        android:layout_marginEnd="25dp"
        android:id="@+id/meme_grid"
        android:layout_centerInParent="true">
    </GridView>
</RelativeLayout>

on my Activity OnCreate, i insert a ZoomView (from pl.polidea.ZoomView) like this:

//Setting the ZoomView from ZoomView.jar library
zoomView = new ZoomView(this);

rlMemeHolder = (RelativeLayout)findViewById(R.id.rlMemeHolder);

rlMemeHolder.removeView(grvMemes);

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
zoomView.setLayoutParams(params);
zoomView.setMaxZoom(4);
rlMemeHolder.addView(zoomView);

FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
params2.gravity = Gravity.CENTER;
params2.setMargins(50,0,50,0);
grvMemes.setLayoutParams(params2);

zoomView.addView(grvMemes);

NOTE: i have tried setting the gridView's height as MATCH_PARENT, no luck, it keeps being able to scroll when overflow. (i want all the grid to fit on screen)

Daniel Andujar
  • 1,184
  • 1
  • 11
  • 22
  • http://stackoverflow.com/questions/7067449/android-how-to-stretch-rows-in-the-gridview-to-fill-screen?answertab=active#tab-top – Nikhil Borad Apr 28 '16 at 12:32
  • If you are fine with horizontal scrolling.. you can go for recyclerView and set layout manager of recyclerview to this - e.g. new GridLayoutManager(this, 3, //The number of rows in the grid LinearLayoutManager.HORIZONTAL, false); – sanedroid Apr 28 '16 at 12:36
  • Nikhil, in the case of the one you posted, he uses a static amount of images, i saw that amswer, it doesn't work on my case, asi don't know if the user will just use 1 image, or N.. – Daniel Andujar Apr 28 '16 at 16:27
  • Pooja, nope, i cant work with horizontal scrolling, the problem is that when i capture the view as a bitmap, i get the image cropped to what's visible on the screen... – Daniel Andujar Apr 28 '16 at 16:28

0 Answers0