- 浏览: 429445 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
sunwang810812:
万分感谢中!!!!!这么多年终于看到一个可运行可解决的方案!! ...
POI 后台生成Excel,在前台显示进度 -
zzb7728317:
LZ正解
Spring Jackson AjaxFileUpload 没有执行回调函数的解决办法 -
sleeper_qp:
lz是在源码上修改的么? 源码的话你重新编译一遍了么? 可 ...
由nutch readseg -dump 中文编码乱码想到的…… -
shenjian430:
请问你改好的程序在写在哪了?
由nutch readseg -dump 中文编码乱码想到的…… -
yinxusen:
It seems to be the bug occur in ...
Mahout Local模式 执行example的注意点
1.在res/layout目录下建立pop view的xml文件:overlay_pop.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="@drawable/bubble_background" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="5px" android:paddingTop="5px" android:paddingRight="5px" android:paddingBottom="20px"> <TextView android:id="@+id/map_bubbleTitle" android:ellipsize="marquee" style="@style/map_BubblePrimary" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:singleLine="true" /> <TextView android:id="@+id/map_bubbleText" style="@style/map_BubbleSecondary" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="false" /> </LinearLayout>
其中用到的style是放在res/values中的style.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="map_BubblePrimary"> <item name="android:textStyle">bold</item> <item name="android:typeface">monospace</item> <item name="android:textColor">#000</item> </style> <style name="map_BubbleSecondary"> <item name="android:textStyle">italic</item> <item name="android:textColor">#000</item> </style> </resources>
另外,作为背景的bubble_background图片是采用采用9.png的格式:
在onCreate中:
MapView是继承自ViewGroup 的,因此,MapView有addView()方法,同时还有MapView.LayoutParams
MapView.LayoutParams 可以根据GeoPoint来定位,我就是利用这个特性来定位弹出的popView的.
View popView = View.inflate(this, R.layout.overlay_pop, null); mapView.addView(popView, new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT, null, MapView.LayoutParams.BOTTOM_CENTER)); popView.setVisibility(View.GONE);
2.实现点击某个Overlay弹出popView。
overlay有onTap()方法,你可以实现自己的overlay onTap()方法,弹出popView,
也可以使用setOnFocusChangeListener(),在listener中实现弹出popView,.
我是用的listener,因为setOnFocusChangeListener在失去焦点也会触发,我可以再失去焦点的时候隐藏popView.
/** * 气泡窗口监听器 */ private final ItemizedOverlay.OnFocusChangeListener onFocusChangeListener = new ItemizedOverlay.OnFocusChangeListener() { @Override public void onFocusChanged(ItemizedOverlay overlay, OverlayItem newFocus) { // 创建气泡窗口 if (popView != null) { popView.setVisibility(View.GONE); } if (newFocus != null) { MapView.LayoutParams geoLP = (MapView.LayoutParams) popView.getLayoutParams(); geoLP.point = newFocus.getPoint();// 这行用于popView的定位 TextView title = (TextView) popView.findViewById(R.id.map_bubbleTitle); title.setText(newFocus.getTitle()); TextView desc = (TextView) popView.findViewById(R.id.map_bubbleText); if (newFocus.getSnippet() == null || newFocus.getSnippet().length() == 0) { desc.setVisibility(View.GONE); } else { desc.setVisibility(View.VISIBLE); desc.setText(newFocus.getSnippet()); } mapView.updateViewLayout(popView, geoLP); popView.setVisibility(View.VISIBLE); } } };
3.自己实现一个继承自ItemizedOverlay的Overlay,
Overlay中有一个
private static final int LAYER_FLAGS = Canvas.MATRIX_SAVE_FLAG | Canvas.CLIP_SAVE_FLAG | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.FULL_COLOR_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG;
private final ArrayList<OverlayItem> overlayItems = new ArrayList<OverlayItem>();
和用于向overlayItems中添加OverlayItem的方法
public void addOverlay(OverlayItem overlay) { overlayItems.add(overlay); populate(); }
在override的draw方法中
@Override public void draw(Canvas canvas, MapView mapView, boolean shadow) { if (!shadow) { canvas.save(LAYER_FLAGS); Projection projection = mapView.getProjection(); int size = overlayItems.size(); Point point = new Point(); Paint paint = new Paint(); paint.setAntiAlias(true); OverlayItem overLayItem; for (int i = 0; i < size; i++) { overLayItem = overlayItems.get(i); Drawable marker = overLayItem.getMarker(0); // marker.getBounds() /* 象素点取得转换 */ projection.toPixels(overLayItem.getPoint(), point); if (marker != null) { boundCenterBottom(marker); } /* 圆圈 */ paint.setColor(Color.RED); canvas.drawCircle(point.x, point.y, 5, paint); /* 标题 */ String title = overLayItem.getTitle(); if (title != null && title.length() > 0) { paint.setColor(Color.BLACK); paint.setTextSize(15); canvas.drawText(title, point.x, point.y, paint); } } canvas.restore(); } super.draw(canvas, mapView, shadow); }
在onCreate中初始化
overlay.addOverlay(new OverlayItem(pointQSH, "清水河", "清水河校区")); overlay.addOverlay(new OverlayItem(pointSH, "沙河", "沙河校区")); overlay.setOnFocusChangeListener(onFocusChangeListener); mapView.getOverlays().add(overlay);
OK,实现效果:
发表评论
-
【转】区分Activity的四种加载模式
2012-01-11 21:33 879转自http://marshal.easymorse.c ... -
【转】Android之完美退出方法(2.1-2.2-2.3SDK版本均测试通过)
2012-01-11 15:49 1270转自:http://hi.baidu.com/xunle ... -
【转】Android程序完全退出的三种方法
2012-01-11 14:38 1059以下为网络上找的文 ... -
在程序中,打开google手机自带的程序Maps
2012-01-11 14:32 922Uri uri = Uri.parse("ht ... -
android keystore
2012-01-11 11:55 968C:\Program Files\Java\jdk1.6 ... -
解决ListView和ExpandableListView滚动时背景变黑
2012-01-10 11:24 1630今天做东西的时候发现ListView和Expandabl ... -
android中intent的作用
2012-01-10 00:25 25111 Intent.ACTION_MAIN St ... -
关于Android中Java与Javascript之间的传值研究
2012-01-10 00:23 2964Android中提供的WebView的功能不可谓不强大, ... -
Android自适应屏幕大小和layout布局(横屏|竖屏)
2011-12-27 14:27 2560一:不同的layout Android手机屏幕大小不一,有48 ... -
从sbf刷机包里提取需要的apk文件
2011-11-18 14:07 25001、首先必然要有刷机包sbf文件 2、用MotoAndroi ... -
MB502 使用心得
2011-08-20 00:34 35811、解决MOTO ME502用不了CMWAP的办法 第 ... -
Android中点中overlay弹出带尾巴的气泡的实现
2010-11-17 20:59 8331.在res/layout目录下建立pop view的xml文 ... -
(转)Android中LocationManager的简单使用,获取当前位置
2010-11-16 21:22 2241Android中LocationManager的提供了一系 ... -
创建指南针View的例子(2)
2010-11-12 15:25 15037. 为了查看指南针,修改main.xml资源,使用你的C ... -
创建指南针View的例子(1)
2010-11-12 15:20 1092在接下来的例子里,你将通过扩展View类创 ... -
Android Bitmap和Canvas学习笔记
2010-11-12 15:18 1109位图是我们开发中最常用的资源,毕竟一个漂亮的界面对用户 ... -
android sqlite3 adb使用
2010-10-04 23:10 14551.首先,emulator必须跑起来。可以通过eclipse或 ...
相关推荐
android中点中overlay弹出带尾巴的气泡的实现
ANDROID中点中OVERLAY弹出带尾巴的气泡的实现
android中点中overlay弹出带尾巴的气泡的实
android中点中overlay弹出带尾巴的气泡的实现
Android 高德地图自定义点聚合marker图片及Overlay点击选中功能的代码实现及布局文件
mars老师写的重写overlay类在google地图上添加标记的程序,代码清楚易懂
android overlay系统 overlay的硬件抽象层 camera系统与上层接口和硬件抽象层
此资料包含 Android学习笔记 - 地图.doc 通过地名获得经纬度并标识在...点中overlay弹出带尾巴的气泡的实现.doc 传递坐标到Google地图.doc android map.doc Android地图和定位学习总结 .doc 希望对大家有帮助。。。。
Voice overlay helps you turn your user's voice into text, providing a polished UX while handling for you the necessary permission. Demo You can clone this repo, then run the Demo ...
DICOM图像,overlay层,包含只有一层overlay,两侧overlay,overlay加原始图像三种DICOM图像。 不少DICOM开源框架对这种图像支持不够,显示有问题。便于测试系统对带有overlay图像的显示是否正确
Overlay Menu Android
主机overlay和网络overlay介绍 .pptx
这是一个地图上显示气泡框的应用,主要是对overlay的继承和气泡框的布局样式。
Overlay组播Overlay组播Overlay组播Overlay组播Overlay组播Overlay组播Overlay组播Overlay组播
NULL 博文链接:https://kabike.iteye.com/blog/2017338
android.frameworkres.overlay_12.apk
本文实例讲述了JS简单实现点击按钮或文字显示遮罩层...点击文字弹出一个DIV层窗口代码</title> <meta charset="urf-8"/> <style> .black_overlay{ display: none; position: absolute; top: 0
(将安装在/ data / app /中) 通过USB电缆连接手机 运行ADB设备以查看ADB是否检测到该设备。 运行“ ADB root” 运行“ ADB重新挂载”(将重新挂载系统分区) 从下载叠加包apk文件 运行ADB推送“ overlay_...
该资源是 Android 应用实现换肤功能的demo程序,同时也是博客文章:http://blog.csdn.net/janice0529/article/details/39999727 中demo程序, 博客中有详细的demo程序设计介绍。