我正试图在地图的onclick中实现onclick监听器 当用户点击地图时,地图将全屏显示 我的地图是屏幕的1/4 这样当用户点击它时我将全屏显示。
我只尝试过这个。
map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
}
});
getLayoutParams无法设置宽度或高度。任何其他方式做我想要的?
答案 0 :(得分:0)
这对我有用:
map.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng point) {
LinearLayout mapFrameLayout = (LinearLayout)findViewById(R.id.mapf);
if (!isMapOpen)
{
LinearLayout.LayoutParams fullMapParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
if (!isDetailsOpen)
{
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.hide(closedDetailsFragment).commit();
mapFrameLayout.setLayoutParams(fullMapParams);
isMapOpen = true;
isDetailsOpenWhenOpenedMap = false;
}
else
{
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.hide(openedDetailsFragment).commit();
mapFrameLayout.setLayoutParams(fullMapParams);
isMapOpen = true;
isDetailsOpenWhenOpenedMap = true;
}
}
else
{
LinearLayout.LayoutParams defaultMapparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 280);
mapFrameLayout.setLayoutParams(defaultMapparams);
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (isDetailsOpenWhenOpenedMap)
{
fragmentTransaction.show(openedDetailsFragment).commit();
}
else
{
fragmentTransaction.show(closedDetailsFragment).commit();
}
isMapOpen = false;
} }
});