Как и какой сделать элемент некликабельным, но чтобы его было видно на другом Layoyt' те (Android studio)

[![введите сюда описание изображения][1]][1]

Делаю кликер игру, Стоит ConstraintLayout (на который когда кликаешь получаешь токены), в него поместил ImageView (небольшая картинка по центру, которую буду менять когда уровень будет повышаться). На данный момент ImageView не отображается по факту. Как сделать чтобы его было видно, но он был некликабельный (т.е. когда кликаю на ImageView, срабатывала логика ConstrainLayout) ? Спасибо.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/fonv1"
    android:orientation="vertical"
    tools:context=".MainActivity">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/level_text"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="@string/level"
            android:textSize="30sp"/>

        <TextView
            android:id="@+id/money_text"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="@string/money"
            android:textSize="30sp"/>
    </LinearLayout>

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:background="@android:color/darker_gray" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/basefonclicker"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/imageView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:srcCompat="@tools:sample/avatars" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</LinearLayout>

Ответы (1 шт):

Автор решения: Tiarait

Если вы установили onClick Listener и хотите его удалить, используйте:

imageView5.setOnClickListener(null);

Или же вы можете просто выключить нажатие, тогда

imageView5.setClickable(false);

как сделать чтобы его было видно

Вы его не видите из-за отсутствия @tools:sample/avatars. tools: * используется только для предварительного просмотра макета Android Studio. Вам нужно подставить свой drawable

Так же рекомендую выставить конкретные размеры layout_width и layout_height для ImageView и android:scaleType="fitCenter"

когда его будет видно как сделать чтобы когда я на него нажимал, срабатывала логика как-будто я нажал на ConstraintLayout

Создать общий onClick Listener для ConstraintLayout и ImageView

→ Ссылка