I would like to know the best way on how to implement horizontal scrolling to only part of the view and vertical scrolling to complete view. I was able to achieve horizontal and vertical scrolling to the complete view. If I have to use layers can you explain a bit more on how to achieve layers and draw shapes on those layers separately.

I tried using two different SurfaceViews it does not work. Here is my code for scrolling horizontally.

@Override public void onDrawFrame(GL10 unused) {


// Set the camera position (View matrix)
Matrix.setLookAtM(mVMatrix, 0, mXOffset, mYOffset, -3, mXOffset, mYOffset, 0f, 0.0f, 1.0f, 0.0f);

// Calculate the projection and view transformation
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);



  • \$\begingroup\$ Are we talking about limiting camera movement or are we talking about drawing some parts of the screen always at the same position (like UI elements)? \$\endgroup\$
    – Mario
    Jan 24, 2013 at 23:10
  • \$\begingroup\$ Thanks for the reply mario. I am not sure but i am guessing restricting the camera movement would be the one but in any case here is my scenario. I have a graph with multiple lines parllel to x-axis with diff y values. Each line has 3 buttons. I want to scroll only the graph not the buttons if the user scrolls Horizontally. If the User scrolls vertically both the buttons and graph has to be scrolled. \$\endgroup\$
    – deepu
    Jan 25, 2013 at 15:15

1 Answer 1


Turns Out My Emulator wasn't working fine but the answer is just have a new Model Matrix created for the buttons without the x offset value in the model matrix.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .