owant / ThinkMap

在 Android 上绘制思维导图控件,让思维更简单。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

使用代码添加节点,map只能显示屏幕这么宽,超出部分无法显示完全

liwentao19881010 opened this issue · comments

private void initTreeView(NodeModel<String> lastNode,List<ThinkMapNodeBean> nodeBeanList){

    for (int i=0;i<nodeBeanList.size();i++){
        ThinkMapNodeBean nodeBean=nodeBeanList.get(i);
        NodeModel<String> nodeModel = new NodeModel<>(nodeBean.getHtml());
        treeModel.addNode(lastNode,nodeModel);

// LogUtil.LogDebug("addNode:"+"("+lastNode.getValue()+",nodeModel="+nodeModel.getValue()+")");
if (nodeBean.getIschild()==1){
List childrenNodes=nodeBean.getChild();
initTreeView(nodeModel,childrenNodes);
}
}
}

使用递归的方式将节点全部添加进去

        initTreeView(nodeTitle,nodeBeanList);
        int dx = ConvertUtil.toPx(this, 20);
        int dy = ConvertUtil.toPx(this, 20);
        int mHeight = ConvertUtil.toPx(this, 720);

        treeView.setTreeLayoutManager(new RightTreeLayoutManager(dx, dy, mHeight));
        treeView.setTreeModel(treeModel);

结果是数据可以正确的按照导图的方式展示出来,但是只能有限的显示几个层级,更多的层级没法完全显示出来,就算移动treeview也看不到,请问大神,要怎么解决这种问题?
screenshot_20171124-104607

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/athens_gray"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:orientation="vertical">

        <com.owant.thinkmap.view.TreeView
            android:id="@+id/edit_map_tree_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </FrameLayout>

我再编辑页面时使用了FrameLayout,主要是为把TreeView的范围局限在它的父控件FrameLayout,因为TreeView是会很大的。不宜直接使用TreeView。这样的话它的大小就是一个问题了。

我之前使用的外部布局是LinearLayout,刚才试了一下你的这个解决方式,果然没有问题了,非常感谢!