谷歌地图,但在加载地图时,标题栏消失了。是否有任何显示标题栏的解决方案?
private void calc_short_Distance() {
String uri = "http://maps.google.com/maps?saddr=" + currentLatitude+","+currentLongitude+"&daddr="+fixedLatitude+","+fixedLongitude;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
//***Title bar displayed upto here and after loading intent it disappear
startActivity(intent);
}
清单代码在这里,主活动类在这里。
您的标题栏不会显示在地图上,因为您以地图应用程序的形式打开地图。 现在,当地图显示时,它不再是您的应用程序,而是Google的应用程序。 如果要控制地图的显示方式,则需要创建自己的带有MapView
的活动,并使用MapView
API绘制方向等。 伪 XML 可能如下所示:
<LinearLayout android:orientation="vertical">
<!--
Whatever you want at the top
-->
<MapView android:layout_width="match_parent" android:layout_height="match_parent" />
</LinearLayout>
然后,您需要通过扩展MapActivity
并使用此 XML 作为其内容视图来创建活动。 然后,您可以使用MapView
API 显示所需的任何叠加层。 您还需要获取用于地图的 API 密钥。 查看Google的MapView教程,以获取有关如何对此活动进行编码的更多信息。
后,请使用意图启动此地图活动,而不是谷歌地图应用。