jianzhongli / MathView

A library for displaying math formula in Android apps.
Apache License 2.0
1.01k stars 188 forks source link

Onclick not working on parent cardview #12

Closed ram-readwhere closed 8 years ago

ram-readwhere commented 8 years ago

Parent cardview is not taking onclick event. if MathView is replaced with plain TextView, then it is working fine.

I am registering onclick as

cvAns.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {   }
            });

And layout file is as

<android.support.v7.widget.CardView
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cvAns"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    card_view:cardUseCompatPadding="true"
    card_view:cardElevation="1dp"
    card_view:cardCornerRadius="1dp"
    android:foreground="?android:attr/selectableItemBackground"
    android:clickable="true"
    card_view:cardBackgroundColor="@color/white">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="5dp">

        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="none">

            <io.github.kexanie.library.MathView
                android:id="@+id/tv_ans"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                auto:engine="KaTeX" />
        </android.support.v4.widget.NestedScrollView>

    </RelativeLayout>

</android.support.v7.widget.CardView>

jianzhongli commented 8 years ago

It seems that MathView, which inherits from WebView, consumes the touch event, this post gave an explanation about this. I just made a quick fix, try upgrade to the newer version 0.0.6 and test if this works for you!

ram-readwhere commented 8 years ago

Hi kexanie, I tried with latest version 0.0.6 but that didn't work.

Do I need to make any changes in my xml or onclick listener?

jianzhongli commented 8 years ago

@ram-readwhere I found that NestedScrollView also consumed the touch event, so just removing the outter NestedScrollView should fix this.

ram-readwhere commented 8 years ago

Hi kexanie,

It is working fine now. Thanks for quick fix.

pranavpari commented 4 years ago

Hello, Can you tell me how you did it?

rahulsain-ingeniumedu commented 2 years ago

It seems that MathView, which inherits from WebView, consumes the touch event, this post gave an explanation about this. I just made a quick fix, try upgrade to the newer version 0.0.6 and test if this works for you!

this disable copy feature, so for those who want to copy text should downgrade to 0.0.5 version