0

I want to create a layout (RelativeLayout) which is larger then Screen, Approx 3500*3500. It has childes on various position which also use touch events to change their position.

What i have done by now is, to decrease scale the layout to a level that user can see all the views.

What my question is, if layout is not scaled(it is in its actual size 3500*3500), how to scroll through the layout to see all the child views?

@Override
protected void dispatchDraw(Canvas canvas) {

    //Save the canvas to set the scaling factor returned from detector
    canvas.save(Canvas.MATRIX_SAVE_FLAG);

    canvas.scale(mScaleFactor, mScaleFactor,gx,gy);

    //canvas.translate(tx, ty);
    super.dispatchDraw(canvas);

    mClipBound = canvas.getClipBounds();

      canvas.restore();
}

I was wondering if i can use canvas.translate(x, y) in touch move? Please suggest?

Kamal
  • 1,415
  • 13
  • 24
  • 1
    Did you considered using GridLayout for this? I think the approach you are asking for could be prone to troubles and that the GridLayout could probably be used for what you are after. If you can not use GridLayout in this case could you please give more info why that is the case? – Igor Čordaš Mar 04 '14 at 15:07
  • @PSIXO i cant use gridview. to be more clear i want a layout like web view. that can be zoomed in zoomed out & can be scrolled. Except the child views of my layout are also movable. – Kamal Mar 04 '14 at 15:09

1 Answers1

1

Android already comes with a view container that is dedicated to all that scrolling business: ScrollView.

FD_
  • 12,947
  • 4
  • 35
  • 62
  • yes i know that, but scroll view is Unidirectional. My layout is larger in both directions. I also tried scroll view in both directions by adding two scroll view but that doesn't work because i have to zoom in & zoom out the layout. – Kamal Mar 04 '14 at 15:07
  • @Kamal see my answer here http://stackoverflow.com/questions/19267763/android-four-directional-navigation – pskink Mar 04 '14 at 15:12
  • @pskink i know its a lame questions, but can i extend your class with relative layout instead of ViewGroup? – Kamal Mar 04 '14 at 15:17
  • @pskink i also have to provide zoom out so that i can see all child views in once. trying to make some changes in your code..any idea? – Kamal Mar 04 '14 at 15:28
  • @Kamal override dispatchDraw ? – pskink Mar 04 '14 at 15:32