GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - alivebao/FreeSizeDraggableLayout: A viewgroup enable custom size of childviews and change their position which has same size by drag

BranchesTags
Open more actions menu

Latest commit

 

History

6 Commits
6 Commits

Folders and files

NameName
Last commit message
Last commit date
app
app
 
 
freesizedraggablelayout
freesizedraggablelayout
 
 
gradle/wrapper
gradle/wrapper
 
 
.gitignore
.gitignore
 
 
FreeSizeDraggableLayout.iml
FreeSizeDraggableLayout.iml
 
 
LICENCE
LICENCE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Android FreeSizeDraggableLayout


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


Analyze

FreeSizeDraggableLayout实现过程解析

Demo

FreeSizeDraggableLayout

Download Demo

Usage


Gradle

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

Maven

<dependency>
  <groupId>com.miao</groupId>
  <artifactId>freesizedraggablelayout</artifactId>
  <version>0.0.2</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.set 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);

PS: Function of change position between group position and draggled item(in v0.0.1, we can just change two view has the same size, we can change the position of whole group of views and the view dragged if they have the same size in v0.0.2. just like the third scenario in demo) is added in version 0.0.2, set it disable if you don't need it:

freeSizeDraggableLayout.setGroupChangeEnable(false);

About

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

Resources

Readme
Apache-2.0 license
Activity

Stars

227 stars

Watchers

8 watching

Forks

26 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.