我有添加自定义注释标注 View 的代码,只要在我的 Skobbler map View 中选择了注释,就会显示该 View 。
@Override
public void onAnnotationSelected(final SKAnnotation annotation) {
...
mapPopup = mapHolder.getCalloutView();
// set the callout view’s background color
mapPopup.setViewColor(Color.WHITE);
View view = getLayoutInflater().inflate(R.layout.map_callout, null);
...
mapPopup.setCustomView(view);
// setting 2nd parameter to 'true' will cause tail to be displayed
mapPopup.showAtLocation(annotation.getLocation(), true);
...
}
我还在 showAtLocation() 调用中请求使用“tail” ImageView 显示标注 View 。但是,当我在应用程序中进行测试时,我看到尾部出现在我的 map_surface_holder RelativeLayout 容器的顶部,而不是显示标注弹出 View 的 FrameLayout 容器的底部。
当我平移 map 时,我可以看到尾 View 相对于标注 View 的移动左右移动,但它仍然与 map_surface_holder 容器的顶部对齐,从不上下移动。
我是否需要在某处添加一些代码来使尾部 ImageView 知道它应该放置在 RelativeLayout 容器的 y 轴方向上的什么位置?
我确实尝试添加对 mapPopup.setVerticalOffset(offset) 的调用以查看是否有任何效果,但尾部图像仍锁定在屏幕顶部。
我可以看到我的自定义标注 View 与 Skobbler 提供的默认 View 之间的另一个区别是,标准 View 是一个 RelativeLayout 容器,而我的实现是一个 FrameLayout。但是,我不确定这是否重要,因为此处的 Tail ImageView 被添加到我的 callout View 的父 View 中,而不是作为 subview 。
预先感谢您在此问题上提供的任何帮助,如果任何其他详细信息对您有帮助,请告诉我。
谢谢!
最佳答案
我们已尝试在 2.5.1 和 3.X 中重现该问题 - 但未能成功。
这是我们使用的代码:
//MapActivity
@Override
onCreate(Bundle savedInstanceState)
{
…
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mapPopup = mapViewGroup.getCalloutView();
View view = inflater.inflate(R.layout.layout_popup, null);
popupTitleView = (TextView) view.findViewById(R.id.top_text);
popupDescriptionView = (TextView) view.findViewById(R.id.bottom_text);
mapPopup.setCustomView(view);
…
}
@Override
public void onAnnotationSelected(final SKAnnotation annotation) {
if (navigationUI.getVisibility() == View.VISIBLE) {
return;
}
// show the popup at the proper position when selecting an
// annotation
int annotationHeight = 0;
float annotationOffset = annotation.getOffset().getY();
switch (annotation.getUniqueID()) {
case 10:
annotationHeight =(int) (64 * getResources().getDisplayMetrics().density);
popupTitleView.setText("Annotation using texture ID ");
popupDescriptionView.setText(null);
break;
case 11:
annotationHeight = customView.getHeight();
popupTitleView.setText("Annotation using custom view");
popupDescriptionView.setText(null);
break;
}
mapPopup.setVerticalOffset(-annotationOffset + annotationHeight / 2);
mapPopup.showAtLocation(annotation.getLocation(), true);
}
//layout_popup.xml
<ImageView
android:id="@+id/left_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:clickable="true"
android:padding="5dp"
android:src="@drawable/icon_map_popup_navigate" />
<LinearLayout
android:id="@+id/mid_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/left_image"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:weightSum="1" >
<TextView
android:id="@+id/top_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Title text"
android:textColor="@color/black"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="@+id/bottom_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:linksClickable="true"
android:text="Subtitle text"
android:textColor="@color/black"
android:textSize="14dp" />
</LinearLayout>
关于java - Skobbler callout tail imageview 显示不正确 Android SDK 2.5.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33794460/
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我正在查看instance_variable_set的文档并看到给出的示例代码是这样做的:obj.instance_variable_set(:@instnc_var,"valuefortheinstancevariable")然后允许您在类的任何实例方法中以@instnc_var的形式访问该变量。我想知道为什么在@instnc_var之前需要一个冒号:。冒号有什么作用? 最佳答案 我的第一直觉是告诉你不要使用instance_variable_set除非你真的知道你用它做什么。它本质上是一种元编程工具或绕过实例变量可见性的黑客攻击
所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
question的一些答案关于redirect_to让我想到了其他一些问题。基本上,我正在使用Rails2.1编写博客应用程序。我一直在尝试自己完成大部分工作(因为我对Rails有所了解),但在需要时会引用Internet上的教程和引用资料。我设法让一个简单的博客正常运行,然后我尝试添加评论。靠我自己,我设法让它进入了可以从script/console添加评论的阶段,但我无法让表单正常工作。我遵循的其中一个教程建议在帖子Controller中创建一个“评论”操作,以添加评论。我的问题是:这是“标准”方式吗?我的另一个问题的答案之一似乎暗示应该有一个CommentsController参
我喜欢使用Textile或Markdown为我的项目编写自述文件,但是当我生成RDoc时,自述文件被解释为RDoc并且看起来非常糟糕。有没有办法让RDoc通过RedCloth或BlueCloth而不是它自己的格式化程序运行文件?它可以配置为自动检测文件后缀的格式吗?(例如README.textile通过RedCloth运行,但README.mdown通过BlueCloth运行) 最佳答案 使用YARD直接代替RDoc将允许您包含Textile或Markdown文件,只要它们的文件后缀是合理的。我经常使用类似于以下Rake任务的东西:
我一直致力于让我们的Rails2.3.8应用程序在JRuby下正确运行。一切正常,直到我启用config.threadsafe!以实现JRuby提供的并发性。这导致lib/中的模块和类不再自动加载。使用config.threadsafe!启用:$rubyscript/runner-eproduction'pSim::Sim200Provisioner'/Users/amchale/.rvm/gems/jruby-1.5.1@web-services/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in`co