All Projects → huxq17 → Handygridview

huxq17 / Handygridview

Licence: apache-2.0
HandyGridView是一个高仿支付宝,网易新闻的高性能的标签可拖动排序的GridView。

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Handygridview

recycler-adapter
RecyclerView-driven declarative UIs
Stars: ✭ 124 (-51.37%)
Mutual labels:  drag-and-drop, android-ui
Tableview
TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
Stars: ✭ 2,928 (+1048.24%)
Mutual labels:  android-ui, gridview
android-tableview-kotlin
Android's missing TableView component.
Stars: ✭ 40 (-84.31%)
Mutual labels:  android-ui, gridview
Fastadapter
The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
Stars: ✭ 3,512 (+1277.25%)
Mutual labels:  android-ui, drag-and-drop
DragBoardView
⭐ Android 看板,支持项拖拽、列拖拽。Draggable kanban/board view for Android.
Stars: ✭ 85 (-66.67%)
Mutual labels:  drag-and-drop, android-ui
FloatingView
FloatingView moved by finger supporting OverlaySystem, OverlayActivity, OverlayViewGroup modes
Stars: ✭ 58 (-77.25%)
Mutual labels:  android-ui
splitImage
把图片分割成n*m份,支持拖拽、input上传
Stars: ✭ 22 (-91.37%)
Mutual labels:  drag-and-drop
XCSkin
Android App中常用的自定义UI库(非第三方)
Stars: ✭ 15 (-94.12%)
Mutual labels:  android-ui
RxUIKotlin
Kotlin designed reactive extensions for the Android UI
Stars: ✭ 26 (-89.8%)
Mutual labels:  android-ui
android-SpringAnimator
A framer.js DHO and RK4 spring animation port for Android.
Stars: ✭ 39 (-84.71%)
Mutual labels:  android-ui
Coffeegram
Android app using Jetpack Compose together with StateFlow and MVI
Stars: ✭ 155 (-39.22%)
Mutual labels:  android-ui
FancyAdapters
A collection of customizable RecyclerView Adapters for Android, that provide various functionality like item selection, contextual action mode controls, drag&drop and swiping, among other.
Stars: ✭ 49 (-80.78%)
Mutual labels:  drag-and-drop
BalloonPopup
Forget Android Toast! BalloonPopup displays a round or squared popup and attaches it to a View, like a callout. Uses the Builder pattern for maximum ease. The popup can automatically hide and can persist when the value is updated.
Stars: ✭ 32 (-87.45%)
Mutual labels:  android-ui
image-uploader
Simple Drag & Drop image uploader plugin to static forms, without using AJAX
Stars: ✭ 70 (-72.55%)
Mutual labels:  drag-and-drop
CustomFontView
Custom View classes for TextView, EditText & Buttons - to set custom fonts
Stars: ✭ 26 (-89.8%)
Mutual labels:  android-ui
RecyclerELE
Android Library for easy addition of Empty, Loading and Error views in a RecyclerView
Stars: ✭ 27 (-89.41%)
Mutual labels:  android-ui
viiny-dragger
viiny-dragger is a drag and drop plugin for javascript.
Stars: ✭ 27 (-89.41%)
Mutual labels:  drag-and-drop
recyclerview-list-drag-and-drop
No description or website provided.
Stars: ✭ 50 (-80.39%)
Mutual labels:  drag-and-drop
JetComposer
Collection of UIs and Animations built with Jetpack Compose for Android
Stars: ✭ 294 (+15.29%)
Mutual labels:  android-ui
FancyTab
No description or website provided.
Stars: ✭ 15 (-94.12%)
Mutual labels:  android-ui

HandyGridView

Android Arsenal

HandyGridView本质上是一个GridView,所以你也可以当成普通的GridView来使用,HandyGridView继承了GridView并在此之上添加了item拖动和交换,绘制图文等功能。 由于只是一个GridView,所以性能比目前其他大部分解决方案都要好。

HandyGridView is a high-performance drag and drop GridView, it extends GridView, you can drag drop GridView item to sort the labels,and draw something on the GridView. Just use the HandyGridView like a GridView.


Screenshots


Usage

Gradle

dependencies {
   compile 'com.huxq17.handygridview:handygridview:1.2.0'

}

minSdkVersion 11

HandyGridView's three modes:

Mode introduction
TOUCH Edit mode,the item can be dragged
LONG_PRESS Long press mode,item can be dragged after long press.
NONE Item can not be dragged, jsut like normal GridView.

Usage:

HandyGridView#setMode(TOUCH|LONG_PRESS|NONE);

Adapter

HandyGridView会在item被拖动交换时发出通知,如果想要做出对应数据上的变化,则可以在Apdater中实现OnItemMovedListener,示例如下:

HandyGridView will send a notification to notify you swip the data source when its item's order is changed. the usage is as follows:


public class GridViewAdapter extends BaseAdapter implements OnItemMovedListener{
    @Override
    public void onItemMoved(int from, int to) {
        String s = mDatas.remove(from);
        mDatas.add(to, s);
    }

    @Override
    public boolean isFixed(int position) {
        //When postion==0,the item can not be dragged.
        if (position == 0) {
            return true;
        }
        return false;
    }
}

绘制图文

HandyGridView提供了在gridview上绘制图文的接口,示例如下:

You can draw something on HandyGridView, the usage is as follows:

    mGridView.setDrawer(new IDrawer() {
            @Override
            public void onDraw(Canvas canvas, int width, int height) {
                if (!mGridView.isNoneMode()) {
                    int offsetX = -DensityUtil.dip2px(MainActivity.this, 10);
                    int offsetY = -DensityUtil.dip2px(MainActivity.this, 10);
                    //文字绘制于gridview的右下角,并向左,向上偏移10dp。
                    //Draw text on the right-bottom of GridView.
                    drawTips(canvas, width + offsetX, height + offsetY);
                }
            }
        },false);

    private void drawTips(Canvas canvas, int width, int height) {
        if (mTextPaint == null) {
            mTextPaint = new TextPaint();
            mTextPaint.setColor(Color.parseColor("#CFCFCF"));
            mTextPaint.setTextSize(DensityUtil.dip2px(MainActivity.this, 12));
            Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();
            textHeight = (int) (fontMetrics.bottom - fontMetrics.top) + 1;
            textWidth = (int) mTextPaint.measureText(paintText) + 1;
        }
        width = width - textWidth;
        height = height - textHeight;
        if (tipsLayout == null) {
            tipsLayout = new StaticLayout(paintText, mTextPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.5f, 0f, false);
        }
        canvas.translate(width, height);
        tipsLayout.draw(canvas);
    }

以上就是主要的用法了,更多的用法可以参考example.

The above is the main usage,click to get more.


更新日志

2018-8-29:
1.解决HandyGridView在没有item并且horizontalSpacing为0dp或者没有设置时触摸会挂掉的问题

2017-12-29:
1.解决某些小米手机上item拖动交换时会闪烁的问题,更新到1.1.0

LICENSE

Apache License 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].