【发布时间】:2016-07-09 06:05:00
【问题描述】:
我已将我的 eclipse 项目导入 Android Studio 并更新为 com.google.android.gms.common.api.GoogleApiClient。
我的项目有一个包含许多片段的主要活动。主页按钮片段中有地图。添加地图见下图:
private void addMap() {
FragmentManager fm = getChildFragmentManager();
if(isGoogleMapsInstalled())
{
if (fragment == null)
{
GoogleMapOptions op = new GoogleMapOptions();
op.zOrderOnTop(true);
op.zoomControlsEnabled(false);
fragment = MapFragment.newInstance(op);
fm.beginTransaction().replace(R.id.homemap_id, fragment).commit();
}
}else
{
Toast.makeText(getActivity(), "Please install google map", Toast.LENGTH_SHORT).show();
}
}
成功运行项目后,地图会隐藏所有放置在其上的视图和按钮。甚至 MainActivity 的菜单滑块也显示在地图下方,但在地图上方工作并且地图变得禁用。
** 编辑 :: 认为这可能是因为一些内存问题,所以在应用程序 gradle 中的代码下方使用,但没有运气。
multiDexEnabled true
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
请帮助解决此问题。 ** 注意 :: 该代码在 Eclipse 中运行良好。
编辑 ::
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_texture_a"
android:orientation="vertical" >
<RelativeLayout android:id="@+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<FrameLayout
android:id="@+id/homemap_id"
android:background="@color/dark_red_text_trans"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<CheckBox
android:id="@+id/traffic_heat_btn"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="70dp"
android:background="@drawable/selector_traffic_toggle"
android:button="@null"
android:checked="false"
android:scaleType="fitCenter" />
<TextView
android:id="@+id/mylocation_btn"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="10dp"
android:layout_marginBottom="70dp"
android:background="@drawable/selector_location_toggle"
android:button="@null"
android:scaleType="fitCenter" />
<HorizontalScrollView
android:id="@+id/box_horizonScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:orientation="horizontal"
android:scrollbars="vertical"
android:visibility="gone" >
<!-- android:background="#aaffffff" -->
<LinearLayout
android:id="@+id/dependent_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
<LinearLayout
android:id="@+id/mask_bottom_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@color/dark_red_text"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="gone" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingBottom="17dp"
android:paddingLeft="20dp"
android:paddingTop="17dp"
android:text="Cancel"
android:textColor="@color/white"
android:textSize="@dimen/text_sizes_smallest"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="DONE"
android:textColor="@color/white"
android:textSize="@dimen/text_sizes_medium"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingRight="15dp"
android:text="Clear Filters"
android:textColor="@color/white"
android:textSize="@dimen/text_sizes_smallest"
android:textStyle="bold"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
你可以发布布局xml文件吗?
-
您的 xml 布局中似乎存在一些问题。请在此处发布您的 xml 文件以获取有关该问题的更多信息。
-
@Raghavendra 我也添加了 xml 布局。请注意它,任何帮助将不胜感激。
-
@ManshaChuttani 我也添加了 xml 布局。请注意它,任何帮助将不胜感激。
标签: java android eclipse google-maps android-fragments