How can I set attribute onClick to a ScrollView?

android, onclick, scrollview

Solution

You could try to let the `LinearLayout` implement the `onClick` attribute and then set:

android:fillViewport="true"

to the `ScrollView`.

Problem

I have the following layout ``` <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/white" > <LinearLayout android:id="@+id/answerMainFrame" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/white" android:isScrollContainer="true" android:onClick="toQuestion" > <ImageView android:id="@+id/answer_img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustViewBounds="true" android:contentDescription="@string/question_img_cd" /> <TextView android:id="@+id/answer" style="@style/Question" /> </LinearLayout> ``` Sometimes the `ScrollView` is too small and won't fill the whole screen but still I want to call the method `toQuestion()` clicking anywhere on the screen. I've tried setting `android:layout_height="wrap_content"` to the `LinearLayout` and `android:onClick="toQuestion"` to the `ScrollView` but same result.

Original source

Related problems