4 images in a LayerDrawable display - only one is displayed

18 views Asked by At

I can't manage to display 4 images in a LayerDrawable. Only one is always displayed. Here is the main code for it

      private fun getClusterIcon(cluster: Cluster<Store>): BitmapDescriptor? {
       
      val profilePhotos: MutableList<Drawable> =  ArrayList(4.coerceAtMost(cluster.size))

      for(store in cluster.items)
      {
          if (profilePhotos.size == 4) break;


                 Picasso.get().load(store.hauptBild).into(object : com.squareup.picasso.Target {
                     override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
                         val drawable: Drawable = BitmapDrawable(ctx.resources,bitmap);
                         drawable.setBounds(0, 0, width, height)
                         profilePhotos.add(drawable)
                     }

                     override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {}

                     override fun onPrepareLoad(placeHolderDrawable: Drawable?) {}


                 })


      }

        val multiDrawable = LayerDrawable(profilePhotos.toTypedArray())
        multiDrawable.setBounds(0, 0, width, height)

        mClusterImageView!!.setImageDrawable(multiDrawable)
        val icon: Bitmap = mClusterIconGenerator.makeIcon(cluster.size.toString())
        return BitmapDescriptorFactory.fromBitmap(icon)

  }

the multi_profil.xml layout:

   <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="2dp"
android:layout_width="@dimen/custom_profile_image"
android:layout_height="@dimen/custom_profile_image">

<ImageView
    android:id="@+id/image"
    android:scaleType="centerCrop"
    android:layout_width="@dimen/custom_profile_image"
    android:layout_height="@dimen/custom_profile_image"/>
  
<TextView
    android:id="@id/amu_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="@style/amu_Bubble.TextAppearance.Light"
    android:background="@android:color/black"
    android:paddingLeft="@dimen/custom_profile_padding"
    android:paddingRight="@dimen/custom_profile_padding"
    android:layout_gravity="center"
    android:alpha=".8"/>

</FrameLayout>
0

There are 0 answers