2

我正在使用 MapCustomClustering 在地图上显示图像。集群图标还显示集群中的项目数,但它没有显示在我的集群中。我正在从 Parse 云加载数据。示例一呈现 cluster.getSize() 但在我的它不起作用。

  @Override
    protected void onBeforeClusterRendered(final Cluster<MapPosts> cluster, final MarkerOptions markerOptions) {
        // Draw multiple people.
        // Note: this method runs on the UI thread. Don't spend too much time in here (like in this example).
        final List<Drawable> profilePhotos = new ArrayList<>(Math.min(4, cluster.getSize()));
        final int width = mDimension;
        final int height = mDimension;
        int i = 0;
        for (MapPosts p : cluster.getItems()) {
            // Draw 4 at most.
            i++;
            Picasso.with(getApplicationContext())
                    .load(String.valueOf(p.profilePhoto))
                    .into(new Target() {
                        @Override
                        public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) {
                            Drawable drawable = new BitmapDrawable(getResources(), bitmap);
                            drawable.setBounds(0, 0, width, height);
                            profilePhotos.add(drawable);
                            MultiDrawable multiDrawable = new MultiDrawable(profilePhotos);
                            multiDrawable.setBounds(0, 0, width, height);
                            mClusterImageView.setImageDrawable(multiDrawable);
                            Bitmap icon = mClusterIconGenerator.makeIcon(String.valueOf(cluster.getSize()));
                            markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
                        }

                        @Override
                        public void onBitmapFailed(Drawable errorDrawable) {
                        }

                        @Override
                        public void onPrepareLoad(Drawable placeHolderDrawable) {

                        }
                    });
            if (profilePhotos.size() == 4) break;
        }

    }

例子

矿

4

1 回答 1

1

我找到了答案 :-) -> 确保你的图标样式中有这样的 TextView!重要的一点是您将其命名为“文本”!

    <TextView
    **android:id="@id/text"**
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/holo_green_dark"
    android:paddingLeft="@dimen/custom_profile_padding"
    android:paddingRight="@dimen/custom_profile_padding"
    android:layout_gravity="center"
    android:alpha=".8"/>
于 2016-06-22T15:59:41.263 回答