大佬教程收集整理的这篇文章主要介绍了如何在Android Iconnenerator上居中文本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
码:
IconGenerator clusterIconGenerator = new IconGenerator(context); clusterIcon = context.getresources().getDrawable(R.drawable.map_cluster); clusterIconGenerator.setBACkground(clusterIcon); @Override protected void onBeforeClusterRendered(Cluster<myType> cluster,MarkerOptions markerOptions) { Bitmap clusterIcon = clusterIconGenerator.makeIcon(String.valueOf(cluster.getSize())); markerOptions.icon(BitmapDescriptorFactory.fromBitmap(clusterIcon)); }
从2016年4月1日开始,在库的资源中添加了一个前缀
所以id =“text”已经改为“amu_text”.
如图书馆文档中所述:
@Override protected void onBeforeClusterRendered(Cluster<Dashboard_Marker> cluster,MarkerOptions markerOptions) { IconGenerator TextMarkerGen = new IconGenerator(context); Drawable marker; int clustersize = cluster.getSize(); marker = context.getresources().getDrawable(R.drawable.cluster_red); TextMarkerGen.setBACkground(R_911_11845@arker); LayoutInflater myInflater = (LayoutInflater)context.getSy@L_674_14@service(Context.LAYOUT_INFLATER_serviCE); View activityView = myInflater.inflate(R.layout.cluster_view,null,falsE); TextMarkerGen.setContentView(activityView); TextMarkerGen.makeIcon(String.valueOf(cluster.getSize())); BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(TextMarkerGen.makeIcon()); markerOptions.icon(icon); }
布局cluster_view为:
<LinearLayout xmlns:android="http://scheR_911_11845@as.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerHorizontal="true" android:layout_centerInParent="true" android:layout_centerVertical="true" android:weightSum="1"> <TextView android:layout_width="61dp" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Medium Text" android:textColor="#000000" android:id="@+id/text" android:layout_marginTop="13dp" android:gravity="center" /> </LinearLayout>
以上是大佬教程为你收集整理的如何在Android Iconnenerator上居中文本全部内容,希望文章能够帮你解决如何在Android Iconnenerator上居中文本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。