title: OnClick method for a custom view has never called (Android)
body: <p>I'm trying to use Custom view that extends <code>RelativeLayout</code> and named <code>CardView</code>. A added some attr and created XML file for them, everything work correct, except <code>onClick</code>. So, at first I've created a special class for my view: </p>
  
  <pre><code>class CardView(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) {
  
  init {
      inflate(context, R.layout.card_view, this)
      val imageView: ImageView = findViewById(R.id.image)
      val textView: TextView = findViewById(R.id.caption)
      val line: ImageView = findViewById(R.id.line)
  
      val attributes = context.obtainStyledAttributes(attrs, R.styleable.CardView)
      imageView.setImageResource(attributes.getResourceId(R.styleable.CardView_image, 0))
      textView.text = attributes.getString(R.styleable.CardView_text)
      line.setBackgroundColor(attributes.getColor(R.styleable.CardView_lineColor, 0))
      attributes.recycle()
  } }
  </code></pre>
  
  <p>I aslo have a xml file for my View: </p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="@dimen/cardSize"
  android:layout_height="@dimen/cardSize"
  android:background="@drawable/card_color_selector"
  android:clickable="true"&gt;
  
  &lt;ImageView
      android:id="@+id/image"
      android:layout_width="60sp"
      android:layout_height="60sp"
      android:layout_centerHorizontal="true"
      android:layout_margin="3sp"
      tools:src="@color/colorPrimary" /&gt;
  
  &lt;TextView
      android:id="@+id/caption"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      style="@style/text_normal"
      android:textSize="15dp"
      android:layout_alignParentBottom="true"
      android:layout_margin="10sp"
      android:gravity="center"
      android:textColor="@color/darkGray"
      tools:text="Caption" /&gt;
  
  &lt;ImageView
      android:id="@+id/line"
      android:layout_width="match_parent"
      android:visibility="visible"
      android:layout_height="5dp"
      android:layout_alignParentBottom="true"
      android:background="@color/colorPrimary" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And finally I've added my <code>customView</code> in activity layout with link to <code>onClick</code> method in view model like here:</p>
  
  <pre><code>&lt;layout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
  &lt;data&gt;
  
      &lt;variable
          name="viewModel"
          type="com.presentation.screen.HomeViewModel" /&gt;
  &lt;/data&gt;
  
  &lt;android.support.constraint.ConstraintLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
  &lt;com.project.presentation.utils.CardView
          android:id="@+id/card"
          android:layout_width="@dimen/cardSize"
          android:layout_height="@dimen/cardSize"
          android:clickable="true"
          android:onClick="@{() -&gt; viewModel.onClick()}"
          app:image="@drawable/icon"
          app:lineColor="@color/colorPrimary"
          app:text="@string/text" /&gt;    
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>So everything is good, colors are changed as i'd written in <code>card_color_selector.xml</code>, but method <code>onClick</code> in my <code>ViewModel</code> has never called. Oh, by the way my view model is here, now I just want to logged all the clicks:</p>
  
  <pre><code>class HomeViewModel : BaseViewModel&lt;Router&gt;() {
  
      fun onClick() {
          Log.e("myLog", "HomeViewModel onClick")
      }
  }
  </code></pre>
  
  <p>I've tried everything! Please help me to figure out what I'm doing wrong. </p>