title: Android: network relationship graph
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <pre><code>GridView gridview = (GridView) findViewById(R.id.gridview);
  gridview.setAdapter(new ButtonAdapter(this));
  </code></pre>
  
  <p>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.</p>
  
  <pre><code>protected Bitmap drawArrow(float startX, float startY, float endX, float endY, Bitmap bitmap) {
  ....
  }
  
  Drawable d = new BitmapDrawable(bitmap);
  gridview.setBackgroundDrawable(d);
  </code></pre>
  
  <p>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?</p>
  
  <p>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.</p>