Marilia
Marilia

Reputation: 1981

Is It possible to click through a ListView?

I have a ListView over a LinearLayout. There are clickable elements in the LinearLayout and since the ListView is transparent I can see those elements, and would like to be able to click on them, but even though the ListView looks transparent, it behaves as a barrier and doesn't let me click on the elements.

Is there a way I can click through the ListView?

If I change the ListView layout_height to wrap_content, it behaves as I want, but I need it to start with a certain height, so the items will stack at the bottom with android:stackFromBottom="true".

This is an example of how the code looks like:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            (Clickable elements)
    </LinearLayout>
    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent"
        android:transcriptMode="normal"
        android:layout_marginTop="100dp"
        android:layout_marginBottom="361dp"
        android:stackFromBottom="true"
        android:listSelector="@android:color/transparent"/>
</RelativeLayout>

Upvotes: 0

Views: 364

Answers (1)

heysupratim
heysupratim

Reputation: 423

Extend listview and override the onTouch() method and pass it down to the underlying views

Upvotes: 1

Related Questions