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 8774029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:27:29+00:00 2026-06-13T18:27:29+00:00

I have two galleries with different size on relative layout above each other. The

  • 0

I have two galleries with different size on relative layout above each other. The gallery behind is smaller than gallery above so I want gallery behind react from touch events if common part of two galleries is touched otherwise the gallery above should react. Currently only gallery above is reacting. Do you have any idea how to realize this ?

  • 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-13T18:27:30+00:00Added an answer on June 13, 2026 at 6:27 pm

    I didn’t try it, but this may help you:

    Override onTouchEvent in your gallary1, then copy the MotionEvent and pass it to the other Gallary lets name it as gallary1

    @Override
        public boolean onTouchEvent(MotionEvent event) {
    
            MotionEvent event2=MotionEvent.obtain(event);
            gallery2.onTouchEvent(event2);
    
            return super.onTouchEvent(event);
        }
    

    Full Code (its working):

    public class MyGallary extends Gallery {
    
        public MyGallary(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
       }
    
    public MyGallary(Context context, AttributeSet attrs) {
        super(context, attrs);
       }
    
    public MyGallary(Context context) {
        super(context);
      }
    
        private MyTouchListener myTouchListener;
    
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (myTouchListener != null) {
                myTouchListener.onTouch(event);
            }
            return super.onTouchEvent(event);
        }
    
        public MyTouchListener getMyTouchListener() {
            return myTouchListener;
        }
    
        public void setMyTouchListener(MyTouchListener myTouchListener) {
            this.myTouchListener = myTouchListener;
        }
    
    }
    

    public interface MyTouchListener {
    
        public void onTouch(MotionEvent event);
    
    }
    

    public class MainActivity extends Activity {
    
        MyGallary gallary1;
        Gallery gallary2;
        MyTouchListener listener1;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            gallary1 = (MyGallary) findViewById(R.id.myGallary1);
            listener1 = new MyTouchListener() {
    
                @Override
                public void onTouch(MotionEvent event) {
                    MotionEvent event2 = MotionEvent.obtain(event);
                    gallary2.onTouchEvent(event2);
    
                }
            };
            gallary1.setMyTouchListener(listener1);
    
            gallary2 = (Gallary) findViewById(R.id.Gallary2);
    
            int[] array = new int[] { R.drawable.ic_launcher,
                    R.drawable.ic_launcher, R.drawable.ic_launcher,
                    R.drawable.ic_launcher, R.drawable.ic_launcher,
                    R.drawable.ic_launcher, R.drawable.ic_launcher };
    
            ImageAdapter adapter1 = new ImageAdapter(array);
            gallary1.setAdapter(adapter1);
    
            ImageAdapter adapter2=new ImageAdapter(array);
            gallary2.setAdapter(adapter2);
    
        }
    
        class ImageAdapter extends BaseAdapter {
    
            int[] array;
    
            public ImageAdapter(int[] array) {
                this.array = array;
            }
    
            @Override
            public int getCount() {
                return array.length;
            }
    
            @Override
            public Object getItem(int position) {
    
                return array[position];
            }
    
            @Override
            public long getItemId(int position) {
                return position;
            }
    
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
    
                if (convertView == null) {
                    ImageView imageView = new ImageView(MainActivity.this);
                    Gallery.LayoutParams params = new Gallery.LayoutParams(
                            Gallery.LayoutParams.MATCH_PARENT,
                            Gallery.LayoutParams.MATCH_PARENT);
    
                    imageView.setLayoutParams(params);
    
                    convertView = imageView;
    
                }
    
                ImageView imageView = (ImageView) convertView;
                imageView.setImageResource((Integer) getItem(position));
    
                return convertView;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these two tables: Galleries - {id,title,description} Images - {id,gallery_id,file} Each gallery has
My rails application has two models, gallery and photo. Galleries have many photos and
I have an activity with two galleries. I want to synchronise both galleries so
I have two applications written in Java that communicate with each other using XML
i have two models binded with section model this two models called (gallery,article),i want
I have two update panels on a page. And I want to update both
I have two vectors, x and y . x is a vector where each
I have a MYSQL database of photo galleries; each row contains a field with
Have two events: $('body').mouseup(function(e){} and $('.toggle').click(function(e){} I only want one of these to trigger.
In my Activity, I have two Gallery items. I am implementing OnItemClickListener so I

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.