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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:18:20+00:00 2026-05-23T00:18:20+00:00

I have a LinearLayout with some nested LinearLayouts, ImageView’s and TextViews. One of the

  • 0

I have a LinearLayout with some nested LinearLayouts, ImageView’s and TextViews. One of the TextView’s have scroll bars. I have the onTouchEvent() method overriden in my LinearLayout class but when you touch the TextView with the scroll bar nothing registers.

Here is my xml file (the TextView in question is the last item in this layout):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:minWidth="310dp"
    android:layout_width="fill_parent">
    <LinearLayout
        android:id="@+id/from_linear_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left">
        <ImageView
            android:src="@drawable/ic_dialog_info"
            android:id="@+id/notification_type_icon_image_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:scaleType="center"
            android:layout_margin="4dp"/>
            <TextView
                android:id="@+id/time_text_view"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:text="Timestamp"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:padding="1dp"
                android:textColorLink="?android:attr/textColorPrimaryDisableOnly"/>
    </LinearLayout>
    <ImageView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/under_contact_image_view"
        android:src="@drawable/divider_horizontal_dark"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitXY"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:paddingBottom="2dp"
        android:paddingTop="2dp" />
    <TextView
        android:text="Notification Text"
        android:id="@+id/notification_text_view"
        android:autoLink="all"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="?android:attr/textColorPrimaryDisableOnly"
        android:layout_width="fill_parent"
        android:gravity="left"
        android:paddingRight="10dp"
        android:paddingLeft="10dp"
        android:textColorLink="?android:attr/textColorPrimaryDisableOnly" 
        android:layout_gravity="left" 
        android:layout_height="70dip"
        android:scrollbars="vertical"/>
</LinearLayout>

Any thoughts on this and if so, does anyone know how to overcome this so that I can implement a touch event on this TextView?

  • 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-05-23T00:18:21+00:00Added an answer on May 23, 2026 at 12:18 am

    I hate to answer my own question but I finally figured this one out. Basically, you must intercept the touch events that the Activity is sent. In the intercept function you can then determine what touch events you want to handle and what events you want to let pass through to the Activity and other child items.

    Here is what I had that enabled me to capture “swipe” or “fling” events while letting all other touch events through (e.g. it lets scroll up and down, long press, button press events through).

        MotionEvent _downMotionEvent;
    
    /**
     * This function intercepts all the touch events.
     * In here we decide what to pass on to child items and what to handle ourselves.
     * 
     * @param motionEvent - The touch event that occured.
     */
    @Override
    public boolean dispatchTouchEvent(MotionEvent motionEvent){
        if (_debug) Log.v("NotificationActivity.dispatchTouchEvent()");
        NotificationViewFlipper notificationViewFlipper = getNotificationViewFlipper();
        switch (motionEvent.getAction()){
            case MotionEvent.ACTION_DOWN:{
                //Keep track of the starting down-event.
                _downMotionEvent = MotionEvent.obtain(motionEvent);
                break;
            }
            case MotionEvent.ACTION_UP:{
                //Consume if necessary and perform the fling / swipe action
                //if it has been determined to be a fling / swipe
                float deltaX = motionEvent.getX() - _downMotionEvent.getX();
                final ViewConfiguration viewConfiguration = ViewConfiguration.get(_context); 
                if(Math.abs(deltaX) > viewConfiguration.getScaledTouchSlop()*2){
                    if (deltaX < 0){
                       //Do work here for right direction swipes.
                       return true;
                    }else if (deltaX > 0){
                       //Do work here for left direction swipes.
                       return true;
                    }
                }
                break;
            }
        }
        return super.dispatchTouchEvent(motionEvent);
    }
    

    I hope that this helps anyone else who ran into a similar problem.

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

Sidebar

Related Questions

Ok I have a ViewFlipper with three LinearLayouts nested inside it. It defaults to
I have an extended ImageView that I'm reusing 7 times horizontally (within a LinearLayout)
Let's assume i got a list of ImageView and TextView with LinearLayout. Now i'm
I have a script that appends some rows to a table. One of the
I have added a LinearLayOut having some buttons My screen is RelativeLayOut it self
lets assume i have a LinearLayout , horizontal that contains a TextView and afterward
i have a simple method that takes a generic List parameter but for some
I have Activity with root LinearLayout. I set some of the components weight to
I have a unknown number of TextView elements some EditText elements and so on,
hi ihave list of some items and each list have one image in left

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.