安卓:网络关系图 [英] Android: network relationship graph

查看:406
本文介绍了安卓:网络关系图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我先解释我努力实现后来就说明我目前的方法来解决它。我很感激​​任何有用的投入即使这将意味着从头开始。如果需要的话,我会添加更多的code或解释。

I'll first explain what I'm trying to achieve and later on explain my current approach to solving it. I'm thankful for any useful input even if it would mean to start from scratch. I'll add more code or explanation if needed.

这将是一个更大的Andr​​oid应用程序的一部分。这部分应显示之前选择的网络内和关系的节点之间的所有节点都在一个滚动视图/布局。的关系应该由节点,哪些节点每个节点在一定时间间隔内能听之间的箭头来合照。节点可悲的是必须点击,因为你必须能够设置应用程序的其他部分的一些选项视图中了。实际数据(节点,邻里关系)最后应当通过从数据库中的web服务返回,但这除了是尚未完全相关的事实,节点的量是不固定的。

This is going to be a part of a bigger Android application. This part should display all nodes within a prior selected network and the relationships between the nodes all in one scrollable view/layout. The relationships should be pictured by arrows between the nodes, showing which nodes each node could 'hear' during a certain interval. The nodes sadly have to be clickable, because you have to able to set some options for other parts of the app within that view already. The actual data (nodes, neighbourhood relationships) should finally be returned via a webservice from a database, but this is not yet entirely relevant apart from the fact that the amount of nodes isn't static.

我目前的做法是创建GridView中使用自定义ButtonAdapter填充它,这样我可以使用自定义的非静态量(透明)按钮。

My current approach to this is to create GridView fill it with a custom ButtonAdapter, that way I can use a non-static amount of custom (transparent) buttons.

GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ButtonAdapter(this));

我已经创建了一个可以在一个位图绘制箭头的方法,我也可以很容易地将其转换为可绘制其设置为GridView的背景。

I have created methods that can draw arrows on a Bitmap and I can also easily set it as the GridView's background by converting it to Drawable.

protected Bitmap drawArrow(float startX, float startY, float endX, float endY, Bitmap bitmap) {
....
}

Drawable d = new BitmapDrawable(bitmap);
gridview.setBackgroundDrawable(d);

我的这种做法的问题是,我会需要知道GridView控件的位图和精确尺寸的按钮或交替总高度和宽度的立场,即1按钮会使用。由于的onCreate内创造它我没有得到在这一点上的实际尺寸虽然。有没有一个解决这个问题?

My issue with that approach is, that I'd need to know the exact size of the GridView for the Bitmap and the position of the buttons or alternatively the total height and width, that 1 button would use. Due to creating it within the onCreate I don't get the actual sizes at this point though. Is there a solution to this problem?

和即使想工作我不知道,只是还没有我是否可以设置背景的方式,将滚动1:1与GridView控件,而不是领缩放

And even if that'd work I'm not sure just yet whether I can set the background in a way that it would scroll 1:1 with the GridView instead of getting scaled.

推荐答案

使用自定义解决 SurfaceView 使用自定义线程,并为每个按钮一个额外的类都简单地画在表面上在它们之间的线一起。滚动必须被单独地实施为好。

Solved with a custom SurfaceView utilizing a custom thread and an extra class for each button which are simply drawn together with the lines between them on the surface. Scrolling had to be individually implemented as well.

这篇关于安卓:网络关系图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆