Coder Social home page Coder Social logo

Specify row height about asymmetricgridview HOT 4 CLOSED

felipecsl avatar felipecsl commented on August 23, 2024
Specify row height

from asymmetricgridview.

Comments (4)

gayathri-nair03 avatar gayathri-nair03 commented on August 23, 2024

Never mind. Found a solution to do this.

from asymmetricgridview.

gonzalomelov avatar gonzalomelov commented on August 23, 2024

How did you do?

from asymmetricgridview.

rayray avatar rayray commented on August 23, 2024

@gayathri-nair03 What is the solution?

from asymmetricgridview.

gayathri-nair03 avatar gayathri-nair03 commented on August 23, 2024

@gonzalomelov & @rayray - I did not reference this library, instead copied all reqd files into my project, so that I could edit some lines of code, as required. U might also try extending the existing classes, for the same requirement. Anyway, here's how I did it.

  1. Go to class AsymmetricGridViewAdapter
  2. Method - getView()
  3. Towards the end of this method, there is a line of code setting the view's layout params. Something like this:
    view.setLayoutParams(new LinearLayout.LayoutParams(getRowWidth(currentItem.getItem()),
    getRowHeight(currentItem.getItem())));
    If you observe, here the row height is being set to one particular value - getRowHeight().
  4. You can change this row height to a px value of your own, as I did -
    //START - Gayatri - Added for specifying row heights
    if (currentItem.getItem().getRowSpan() == 1) {
    view.setLayoutParams(
    new LinearLayout.LayoutParams(getRowWidth(currentItem.getItem()),
    context.getResources()
    .getDimensionPixelSize(
    R.dimen.photo_grid_height)));
    } else {
    view.setLayoutParams(
    new LinearLayout.LayoutParams(getRowWidth(currentItem.getItem()),
    context.getResources()
    .getDimensionPixelSize(
    R.dimen.hor_photo_height)));
    }
    //Added block ends here

P.S - I see that this library has undergone a refactoring now, with support for Recycler View. I have worked with the previous version.
Hope this helps.

from asymmetricgridview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.