I am trying to add an image view as a banner on top of recycler view. so in some condition I can hide (View.GONE) or to show that banner image view (View.VISIBLE). but the problem is, the banner image view will never show when I run the app, even though I have set android:visibility="visible"
on the image view xml.
as you can see, I have image view with red background, but that red background image view will not displaying
how to solve this ?
the layout in my fragment is like this
and here is the xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Fragments.Search.SearchKeywordResultFragment"
android:id="@+id/constraintLayout_search_keyword_fragment">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
android:scrollbars="vertical"
tools:listitem="@layout/item_general_event"
android:id="@+id/recyclerView_keyword_search_result"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<ImageView
android:id="@+id/imageView_banner_search_keyword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#E91E63"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@+id/recyclerView_keyword_search_result"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:src="@tools:sample/avatars[3]" />
</androidx.constraintlayout.widget.ConstraintLayout>
Because on your imageView have code line tools:src="@tools:sample/avatars[3]"
Tools function it will only show on android layout editor.
try change into real Image from bitmap or from drawable at app:srcCompat="@drawable/{your_drawable_or_mipmap_data_file}"