'In android, What functions are called when a view is clicked?

I have a layout like this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/llRoot"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ripple_effect"
    android:gravity="center"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/tv6LACK"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:text="6LACK"
        android:textColor="@color/white"
        android:textSize="40sp" />
</LinearLayout>

The ripple's xml

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/white">

    <item android:id="@android:id/mask"
        android:drawable="@color/white"/>

    <item android:drawable="@color/teal_700"/>

</ripple>

My intention is to display the ripple effect for the LinearLayout whenever the TextView with id 'tv6LACK' is clicked. The following code doesn't seem to do anything.

val myTextView: TextView = findViewById(R.id.tv6LACK)
val myLinearLayout: LinearLayout = findViewById(R.id.llRoot)

myTextView.setOnClickListener {
    myLinearLayout.performClick()
}

Is performClick() not equivalent to physically clicking the LinearLayout?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source