Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:51:16+00:00 2026-06-11T18:51:16+00:00

I have a layout (which extends a framelayout) with a gridview and an imageview.

  • 0

I have a layout (which extends a framelayout) with a gridview and an imageview. I scroll through the layout with an onTouchListener,. In my Galaxy Nexus it works fine, but in AVD and other devices (Galaxy SII for example) the view shakes and I can’t find out why.

XML

<paricio.toni.caththemole.MyFrameLayout
    android:id="@+id/campo"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/zonaMarcador" >
    <ImageView
        android:id="@+id/fondo"
        android:layout_width="800dp"
        android:layout_height="800dp"
        android:contentDescription="@android:string/untitled"
        android:src="@drawable/terrenoarena" />
    <GridView
        android:id="@+id/gridView1"
        android:layout_width="640dp"
        android:layout_height="640dp"
        android:layout_gravity="center"
        android:clickable="true"
        android:columnWidth="80dp"
        android:horizontalSpacing="0dp"
        android:numColumns="8"
        android:overScrollMode="never"
        android:scrollbars="none"
        android:stretchMode="columnWidth"
        android:verticalSpacing="0dp" >

    </GridView>

And setOnTouchListener code:

    gridview.setOnTouchListener(new OnTouchListener() { 
        public boolean onTouch(View v, MotionEvent event) {
            int desplazamiento[]={0,0};
            campo.getLocationOnScreen(desplazamiento);
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    mx = event.getX();
                    my = event.getY();
                    return false;
                case MotionEvent.ACTION_MOVE:
                    curX = event.getX();
                    curY = event.getY();
                    campo.scrollBy((int) (mx - curX), (int) (my - curY));                 
                    mx = curX;
                    my = curY;
                    return false;
                case MotionEvent.ACTION_UP:
                    curX = event.getX();
                    curY = event.getY();
                    campo.scrollBy((int) (mx - curX), (int) (my - curY));
                    return false;
            }
            return false;
        }
    });

MyFrameLayout is a FrameLayout extended to be bigger than the screen:

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(0, 0);
}

I can scroll an ImageView in AVD without shake, but if I move the image and gridview (instead of the frame) the views move differently (and wrong). I have tried many things but I can’t avoid the shake. ¿Any idea?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:51:18+00:00Added an answer on June 11, 2026 at 6:51 pm

    I solved shake moving contents:

        gridview.setOnTouchListener(new OnTouchListener() { 
            public boolean onTouch(View v, MotionEvent event) {
                int desplazamiento[]={0,0};
                fondo.getLocationOnScreen(desplazamiento);
                Log.i("miTraza","touch event");
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        Log.i("miTraza","touch event down");
                        mx = event.getX();
                        my = event.getY();
                        return true;
                    case MotionEvent.ACTION_MOVE:
                        Log.i("miTraza","touch move");
                        curX = event.getX();
                        curY = event.getY();
                        fondo.scrollBy((int) (mx - curX), (int) (my - curY));
                        gridview.scrollBy((int) (mx - curX), (int) (my - curY));
                        mx = curX;
                        my = curY;
                        return true;
                    case MotionEvent.ACTION_UP:
                        Log.i("miTraza","touch up");
                        curX = event.getX();
                        curY = event.getY();
                        fondo.scrollBy((int) (mx - curX), (int) (my - curY));
                        gridview.scrollBy((int) (mx - curX), (int) (my - curY));
                        return true;
                }
                return false;
            }
        })
    

    Now gridview and imageview moves together without shakes, I had a problem with onItemClick with gridview but this is another history.

    Thanks to android developer for your help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom layout which extends ViewGroup. Everything is working fine and
I have a CustomButton class (extends LinearLayout ) where I inflate a layout which
I have a layout which looks like this: <LinearLayout> <ImageView> android:width=wrap_content android:height:wrap_content ... </ImageView>
I have a layout setup which can be view here: http://jsfiddle.net/Pn3ts/ It all works
i have a activity which extends ListActivity. The Layout contains some generic widget an
I have a Layout class which extends JFrame . Later I am adding RoadPanel
I have a layout which I am inflating in order to dynamically add TableRows
I have an xml layout which I use for each row in my listview:
Help needed.. I have a organization layout which have rectangular shapes not in an
I have a quite complicated HTML/CSS layout which I would like to convert to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.