In Android, how to detect Click and LongClick in ScrollView
<p>I have very simple activity: just TextView inside ScrollView.</p>

<p>I want to handle user clicks and longclicks on whole ScrollView to start some action. I can easily handle click events on TextView, but cannot on ScrollView.</p>

<p>When text content is long enough it's not a problem, but when it's just one line of text than user needs to click that particular line (top of the screen) which is not very usefull.</p>

<p>How to detect click events in ScrollView? (or any other solution)</p>

<p>Sample activity:</p>

<pre><code>public class TestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);
}

public void testOnClick(View view) {
    Log.d("TestActivity", "Hello? Anybody there?");
    finish();
}}
</code></pre>

<p>And layout:</p>

<pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"&gt;

&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ff0000"
    android:clickable="true"
    android:onClick="testOnClick"&gt;

    &lt;TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="test text\n test text\n test text" /&gt;
&lt;/ScrollView&gt;
</code></pre>

<p></p>