FitGridView
ceryle
52
Visit GitHub RepoGrid Views

Android Arsenal

FitGridView

poster
In this library, GridView is extended with a few methods to achieve fitting it to a given size.

Preview

preview

Installation

Gradle

Add it to your build.gradle with:

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

and:

dependencies {
    compile 'com.github.ceryle:FitGridView:v1.0.5'
}

Customization

Some Attributes

Segmented Button

Option Name Format Description
app:row integer number of rows
app:column integer number of colums

Examples

In Xml Layout
<co.ceryle.fitgridview.FitGridView
     android:id="@+id/gridView"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:listSelector="@android:color/transparent"
     app:column="3"
     app:row="4"/>
In Java
in your main activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    gridView = (FitGridView) findViewById(R.id.gridView);
    gridView.setFitGridAdapter(new Adapter(this));
        
    // you can change grid view size any time. don't forget calling update method.
    changeSize(4, 4);
}
        
private void changeSize(int r, int c) {
     gridView.setRow(r);
     gridView.setColumn(c);
     gridView.update();
}
in your adapter:
// In adapter, you can define your grid size by passing it to super method.
int dataSize = 15;
Adapter(Context context) {
        super(context, R.layout.grid_item, dataSize);
        this.context = context;
}

License

This project is licensed under the Apache License Version 2.0 - see the LICENSE.md file for details

Become a better Android Developer
Millions of developers are learning at MindOrks

Online Training Program

Featured Blogs

Our Team

MindOrks is Certainly one of the best online blog to stay on top of all the Android development news, coding and design patterns. Finally a blog I can count on to keep myself updated with latest and greatest things happening in Android world.

Vipul Shah
Android Developer
Microsoft

Become Pro in Android by watching videos

OUR LEARNERS WORK AT