Tree View; Mind map; Think map; tree map

Overview

GysoTreeView

中文】【英文

Tree View; Mind map; Think map; tree map; 树状图;思维导图;

A custom tree view for Android, designed for easy drawing some tree nodes (e.g. thind mind and tree nodes). Includes smoothly zoom, move, limit and center fix animation support, and allows easy extension so you can add your own child node's customs view and touch event detection.

Releases & downloads

Steps for use

Before presentation, Animal class means you own bean class, like this:

public class Animal {
    public int headId;
    public String name;
}

To use a tree view, you should do 4 steps as follows:

  1. Customs adapter by extends TreeViewAdapter.

    onCreateViewHolder(@NonNull ViewGroup viewGroup, NodeModel node) { //TODO in inflate item view NodeBaseLayoutBinding nodeBinding = NodeBaseLayoutBinding.inflate(LayoutInflater.from(viewGroup.getContext()),viewGroup,false); return new TreeViewHolder<>(nodeBinding.getRoot(),node); } @Override public void onBindViewHolder(@NonNull TreeViewHolder holder) { //TODO get view and node from holder, and then control your item view View itemView = holder.getView(); NodeModel node = holder.getNode(); ... } @Override public Baseline onDrawLine(DrawInfo drawInfo) { // TODO If you return an BaseLine, line will be draw by the return one instead of TreeViewLayoutManager's // if(...){ // ... // return dashLine; // } return null; } } ">
    public class AnimalTreeViewAdapter extends TreeViewAdapter<Animal> {
        private DashLine dashLine =  new DashLine(Color.parseColor("#F06292"),6);
        @Override
        public TreeViewHolder<Animal> onCreateViewHolder(@NonNull ViewGroup viewGroup, NodeModel<Animal> node) {
            //TODO in inflate item view
            NodeBaseLayoutBinding nodeBinding = NodeBaseLayoutBinding.inflate(LayoutInflater.from(viewGroup.getContext()),viewGroup,false);
            return new TreeViewHolder<>(nodeBinding.getRoot(),node);
        }
    
        @Override
        public void onBindViewHolder(@NonNull TreeViewHolder<Animal> holder) {
            //TODO get view and node from holder, and then control your item view
            View itemView = holder.getView();
            NodeModel<Animal> node = holder.getNode();
    		...
        }
    
        @Override
        public Baseline onDrawLine(DrawInfo drawInfo) {
            // TODO If you return an BaseLine, line will be draw by the return one instead of TreeViewLayoutManager's
    		// if(...){
            //   ...
            // 	 return dashLine;
       		// }
            return null;
        }
    }
  2. configure layout manager. Space unit is dp. You can custom you line by extends {@link com.gyso.treeview.line.BaseLine}

    int space_50dp = 50;
    int space_20dp = 20;
    //choose a demo line or a customs line. StraightLine, PointedLine, DashLine, SmoothLine are available.
    Baseline line =  new DashLine(Color.parseColor("#4DB6AC"),8);
    //choose layoout manager. VerticalTreeLayoutManager,RightTreeLayoutManager are available.
    TreeLayoutManager treeLayoutManager = new RightTreeLayoutManager(this,space_50dp,space_20dp,line);
  3. setting adapter and layout manager for your tree view.

    ...
    treeView = findViewById(R.id.tree_view);   
    TreeViewAdapter adapter = new AnimlTreeViewAdapter();
    treeView.setAdapter(adapter);
    treeView.setTreeLayoutManager(treeLayoutManager);
    ...
  4. nodes data setting

    treeModel = new TreeModel<>(root); //Other nodes. NodeModel node1 = new NodeModel<>(new Animal(R.drawable.ic_02,"sub0")); NodeModel node2 = new NodeModel<>(new Animal(R.drawable.ic_03,"sub1")); NodeModel node3 = new NodeModel<>(new Animal(R.drawable.ic_04,"sub2")); NodeModel node4 = new NodeModel<>(new Animal(R.drawable.ic_05,"sub3")); NodeModel node5 = new NodeModel<>(new Animal(R.drawable.ic_06,"sub4")); //Build the relationship between parent node and childs,like: //treeModel.add(parent, child1, child2, ...., childN); treeModel.add(node0, node1, node2); treeModel.add(node1, node3, node4); treeModel.add(node2, node5); //finally set this treeModel to the adapter adapter.setTreeModel(treeModel); ">
    //Create a TreeModel by using a root node.
    NodeModel<Animal> node0 = new NodeModel<>(new Animal(R.drawable.ic_01,"root"));
    TreeModel<Animal> treeModel = new TreeModel<>(root);
    
    //Other nodes.
    NodeModel<Animal> node1 = new NodeModel<>(new Animal(R.drawable.ic_02,"sub0"));
    NodeModel<Animal> node2 = new NodeModel<>(new Animal(R.drawable.ic_03,"sub1"));
    NodeModel<Animal> node3 = new NodeModel<>(new Animal(R.drawable.ic_04,"sub2"));
    NodeModel<Animal> node4 = new NodeModel<>(new Animal(R.drawable.ic_05,"sub3"));
    NodeModel<Animal> node5 = new NodeModel<>(new Animal(R.drawable.ic_06,"sub4"));
    
    
    //Build the relationship between parent node and childs,like:
    //treeModel.add(parent, child1, child2, ...., childN);
    treeModel.add(node0, node1, node2);
    treeModel.add(node1, node3, node4);
    treeModel.add(node2, node5);
    
    //finally set this treeModel to the adapter
    adapter.setTreeModel(treeModel);

Notes & limitations

Firstly, only vertical-down derection layout and right direction layout is available, more layout style should be code.

Secondly, customing lines by extends BaseLine may be a little complicate for Android beginner, and performance issues will happen if you using carefully.

Finally, this custom view will be continuely improved, if you has some innovative ideas, please tell me. Thanks for you patience.

I will tell you how it works on my CSDN blogs.

You might also like...
TourGuide is an Android library that aims to provide an easy way to add pointers with animations over a desired Android View

TourGuide TourGuide is an Android library. It lets you add pointer, overlay and tooltip easily, guiding users on how to use your app. Refer to the exa

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images.  Plugins are available for features like markers, hotspots, and path drawing.
TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.

This project isn't maintained anymore. It is now recommended to use https://github.com/peterLaurence/MapView. MapView is maintained by Peter, one of o

A cool Open Source CoverFlow view for Android with several fancy effects.
A cool Open Source CoverFlow view for Android with several fancy effects.

FancyCoverFlow THIS PROJECT IS NO LONGER MAINTAINED! What is FancyCoverFlow? FancyCoverFlow is a flexible Android widget providing out of the box view

A simple, customizable and easy to use swipeable view stack for Android.
A simple, customizable and easy to use swipeable view stack for Android.

SwipeStack A simple, customizable and easy to use swipeable view stack for Android. QuickStart Include the Gradle dependency dependencies { compil

View that imitates Ripple Effect on click which was introduced in Android L  (for Android 2.3+)
View that imitates Ripple Effect on click which was introduced in Android L (for Android 2.3+)

RippleView View that imitates Ripple Effect on click which was introduced in Android L. Usage For a working implementation, Have a look at the Sample

Expand your view with no problem ;)
Expand your view with no problem ;)

MaryPopup Expand your view with no problem ;) Usage Open marypopup from a view MaryPopup marypopup = MaryPopup.with(context) .

Custom android music player view.
Custom android music player view.

InteractivePlayerView Custom android music player view. Screen Check it on youtube Usage(XML) Define it in your xml file. co.mobiwise.library.Intera

Shadow layout, shadow view for android.
Shadow layout, shadow view for android.

ShadowViewHelper Shadow layout, shadow view for android. How to use: It's very simple to use. Gradle(Check newest version): compile 'com.github.wangji

Show triangle view.
Show triangle view.

TriangleLabelView Show triangle view. How to Use To see how the TriangleLabelView are added to your xml layouts, check the sample project. jp.shts.an

Comments
  • 删除节点

    删除节点

    请问怎么删除父节点下的所有子节点,同时不要删除父节点?现在项目里的代码是删除一个父节点后把子节点和当前节点都删了,所有我通过遍历每个子节点进行删除,但是在不使用删除节点动画时可以通过便利删除每个节点(虽然可以实现删除功能但是删除后视图会抖动偏移),而当设置删除动画为true时节点会出现删不掉的bu g

    opened by MinDaren 4
  • Now Can Exactly Add or remove a node 😀

    Now Can Exactly Add or remove a node 😀

    Done Some changes in ' MainActivity.java '

    • Now You User can Directly choose To which Node he wants to delete
    • An from which node he wants to has child nodes
    • user can do this all stuff by just click on the item

    Hope It is Fine 😀

    MainActivity.zip

    opened by DarkCode462 1
  • 只有VerticalTreeLayoutManager与RightTreeLayoutManager两种布局

    只有VerticalTreeLayoutManager与RightTreeLayoutManager两种布局

    implementation 'io.github.guaishoun:gyso-treeview:1.0.1' 只有VerticalTreeLayoutManager 和 RightTreeLayoutManager 两种布局方式

    下载的里面却有好多种布局 RightTreeLayoutManager LeftTreeLayoutManager CompactRightTreeLayoutManager CompactLeftTreeLayoutManager …………………………

    opened by h79314711 1
Releases(v1.2)
Owner
怪兽N
Try a better life.
怪兽N
Android View for displaying and selecting values in a circle-shaped View, with animations and touch gestures.

CircleDisplay Android View for displaying and selecting (by touch) values / percentages in a circle-shaped View, with animations. Features Core featur

Philipp Jahoda 287 Nov 18, 2022
用于做Path动画的自定义View。 I have a path.I have a view. (Oh~),Path(Anim)View.

PathAnimView 用于做Path动画的自定义View。 I have a path.I have a view. (Oh~),Path(Anim)View. 现已经找到图片->SVG->PATH的正确姿势, Now i have a pic.I have a view. Oh~,Path(A

张旭童 1.1k Oct 28, 2022
A view that allows to paint and saves the result as a bitmap

Android Drawable View Sample app: An Android view that allows to paint with a finger in the screen and saves the result as a Bitmap. Importing to your

Christian Panadero 581 Dec 13, 2022
Provides 9-patch based drop shadow for view elements. Works on API level 9 or later.

Material Shadow 9-Patch This library provides 9-patch based drop shadow for view elements. Works on API level 14 or later. Target platforms API level

Haruki Hasegawa 481 Dec 19, 2022
Snake View is a simple and animated linear chart for Android.

Snake View Snake library is a simple and animation line chart for Android. Latest Version How to use Configuring your project dependencies Add the lib

Txus Ballesteros 339 Dec 14, 2022
Helper class to make any view rotatable

Rotatable This is a helper class actually, it simplifies having a view as rotatable by setting touch events and handling a lot of boilerplate works! S

Yahya Bayramoğlu 300 Nov 11, 2022
(Deprecated) A custom view component that mimics the new Material Design Bottom Navigation pattern.

BottomBar (Deprecated) I don't have time to maintain this anymore. I basically wrote the whole library in a rush, without tests, while being a serious

Iiro Krankka 8.4k Dec 29, 2022
[] A simple way to "badge" any given Android view at runtime without having to cater for it in layout

Android ViewBadger A simple way to "badge" any given Android view at runtime without having to cater for it in layout. Note: If your aim is to replica

Jeff Gilfelt 3k Nov 28, 2022
Android view with both path from constructed path or from svg.

android-pathview You want to animate svg or normal Paths?<br> Change the color, pathWidth or add svg.<br> Animate the "procentage" property to make th

Georgi Eftimov 2.9k Dec 27, 2022
A horizontal view scroller library for Android

View Flow for Android ViewFlow is an Android UI widget providing a horizontally scrollable ViewGroup with items populated from an Adapter. Scroll down

Patrik Åkerfeldt 1.8k Dec 29, 2022