Giter Site home page Giter Site logo

ksharpdabu / freesizedraggablelayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alivebao/freesizedraggablelayout

0.0 1.0 0.0 951 KB

A viewgroup enable custom size of childviews and change their position which has same size by drag

License: Apache License 2.0

Java 100.00%

freesizedraggablelayout's Introduction

##Android FreeSizeDraggableLayout


A viewgroup enable custom size of childviews and change their position which has same size by drag


###Demo

FreeSizeDraggableLayout

Download Demo

###Usage

Gradle

dependencies {
   compile 'com.miao:freesizedraggablelayout:0.0.1'
}

Maven

<dependency>
  <groupId>com.miao</groupId>
  <artifactId>freesizedraggablelayout</artifactId>
  <version>0.0.1</version>
  <type>pom</type>
</dependency>

Use it in your own code:

1.create the viewgroup on your xml:

	<com.miao.freesizedraggablelayout.FreeSizeDraggableLayout
        android:id="@+id/fsd_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

2.get the viewgroup and set the size of it

FreeSizeDraggableLayout fsdLayout = (FreeSizeDraggableLayout) findViewById(R.id.fsd_layout);
fsdLayout.setUnitWidthNum(4);
fsdLayout.setUnitHeightNum(4);

3.create a DetailView list:

List<DetailView> list = new ArrayList<>();
/*
DetailView:
public DetailView(Point p, int width, int height, View v) {
    setPoint(p);
    setWidhtNum(width);
    setHeightNum(height);
    setView(v);
}
*/
list.add(new DetailView(new Point(0, 0), 2, 2, createButton(1)));
list.add(new DetailView(new Point(2, 0), 2, 2, createButton(2)));
list.add(new DetailView(new Point(0, 2), 2, 2, createButton(3)));
list.add(new DetailView(new Point(2, 2), 2, 2, createButton(4)));
/*
private Button createButton(int i) {
    final Button btn = new Button(getApplicationContext());
    btn.setText("Button - " + i);
    btn.setBackgroundColor(Color.BLACK);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), btn.getText(), Toast.LENGTH_SHORT).show();
        }
    });
    return btn;
}
*/

4.set the list as ViewGroup's datasource

freeSizeDraggableLayout.setList(list);

you can get how to use it easily at demo's MainActivity

####Defect

1.data is just set by the function "setlist" in viewgroup(freeSizeDraggableLayout), an adapter will added in next version

2.Event dispatch in FreeSizeDraggableLayout is a mess

freesizedraggablelayout's People

Contributors

alivebao avatar

Watchers

AlexY avatar

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.