样式调整
This commit is contained in:
@@ -263,7 +263,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
FrameLayout.LayoutParams bottomParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
bottomParams.gravity = Gravity.BOTTOM;
|
||||
container.addView(bottomContainer, bottomParams);
|
||||
container.setPadding(0,0,0,dp2px(65));
|
||||
container.setPadding(0, 0, 0, dp2px(65));
|
||||
|
||||
|
||||
// --- 模式选择菜单 ---
|
||||
@@ -272,7 +272,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
// 布局参数:位于规划按钮上方
|
||||
FrameLayout.LayoutParams menuParams = new FrameLayout.LayoutParams(dp2px(130), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
menuParams.gravity = Gravity.BOTTOM | Gravity.END;
|
||||
menuParams.setMargins(0, 0, dp2px(15), dp2px(330)); // 高度根据按钮位置调整
|
||||
menuParams.setMargins(0, 0, dp2px(15), dp2px(230)); // 高度根据按钮位置调整
|
||||
container.addView(modeMenu, menuParams);
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
int layoutSize = dp2px(44);
|
||||
FrameLayout.LayoutParams toggleParams = new FrameLayout.LayoutParams(layoutSize, layoutSize);
|
||||
toggleParams.gravity = Gravity.BOTTOM | Gravity.END;
|
||||
toggleParams.setMargins(0, 0, dp2px(12), dp2px(340)); // 位于定位按钮上方
|
||||
toggleParams.setMargins(0, 0, dp2px(12), dp2px(210)); // 位于定位按钮上方
|
||||
container.addView(planToggleBtn, toggleParams);
|
||||
|
||||
// --- 右下角定位按钮 ---
|
||||
@@ -316,7 +316,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 15f));
|
||||
});
|
||||
FrameLayout.LayoutParams locParams = new FrameLayout.LayoutParams(layoutSize, layoutSize);
|
||||
locParams.setMargins(0, 0, dp2px(15), dp2px(285)); // 调高一点,避开底部的面板
|
||||
locParams.setMargins(0, 0, dp2px(15), dp2px(150)); // 调高一点,避开底部的面板
|
||||
locParams.gravity = Gravity.BOTTOM | Gravity.END;
|
||||
container.addView(mLocBtn, locParams);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
private LinearLayout createDetailPanel(Context context) {
|
||||
LinearLayout panel = new LinearLayout(context);
|
||||
panel.setOrientation(LinearLayout.VERTICAL);
|
||||
int padding = dp2px(20);
|
||||
int padding = dp2px(15);
|
||||
panel.setPadding(padding, padding, padding, padding);
|
||||
|
||||
// --- (包含标题和关闭按钮) ---
|
||||
@@ -347,11 +347,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
ivClose.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
ivClose.setPadding(dp2px(5), dp2px(5), dp2px(5), dp2px(5));
|
||||
ivClose.setOnClickListener(v -> {
|
||||
if (detailPanel != null)
|
||||
detailPanel.setVisibility(View.GONE);
|
||||
searchArea.setVisibility(View.VISIBLE);
|
||||
planToggleBtn.setVisibility(View.VISIBLE);
|
||||
mLocBtn.setVisibility(View.VISIBLE);
|
||||
resetView();
|
||||
});
|
||||
|
||||
LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(dp2px(28), dp2px(28));
|
||||
@@ -430,6 +426,14 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void resetView() {
|
||||
if (detailPanel != null)
|
||||
detailPanel.setVisibility(View.GONE);
|
||||
searchArea.setVisibility(View.VISIBLE);
|
||||
planToggleBtn.setVisibility(View.VISIBLE);
|
||||
mLocBtn.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private boolean isGetInputtips = false;
|
||||
|
||||
private void calculateRouteBeforeNavi() {
|
||||
@@ -811,6 +815,18 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
aMap.setMyLocationEnabled(true);
|
||||
aMap.setOnMarkerClickListener(this);
|
||||
|
||||
// 添加地图点击监听,当 detailPanel 显示时点击地图就执行 resetView
|
||||
aMap.setOnMapClickListener(latLng -> {
|
||||
if (detailPanel != null && detailPanel.getVisibility() == View.VISIBLE) {
|
||||
resetView();
|
||||
}
|
||||
});
|
||||
aMap.setOnPOIClickListener(poi -> {
|
||||
if (detailPanel != null && detailPanel.getVisibility() == View.VISIBLE) {
|
||||
resetView();
|
||||
}
|
||||
});
|
||||
|
||||
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
||||
try {
|
||||
Bitmap carBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.car);
|
||||
@@ -823,7 +839,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
}
|
||||
|
||||
myLocationStyle.anchor(0.5f, 0.5f);
|
||||
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
||||
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_SHOW);
|
||||
aMap.setMyLocationStyle(myLocationStyle);
|
||||
aMap.getUiSettings().setZoomControlsEnabled(false);
|
||||
aMap.getUiSettings().setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_LEFT);
|
||||
@@ -1035,6 +1051,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
dataMap.put("latLng", latLng);
|
||||
dataMap.put("stationId", stationId);
|
||||
dataMap.put("address", address);
|
||||
dataMap.put("name", name);
|
||||
m.setObject(dataMap);
|
||||
|
||||
stationMarkers.add(m);
|
||||
@@ -1045,7 +1062,27 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
|
||||
//地图选点
|
||||
for (Marker m : stationMarkers) {
|
||||
m.setIcon(BitmapDescriptorFactory.fromResource(m.equals(marker) ? R.drawable.ic_marker : R.drawable.ic_un_marker));
|
||||
Object obj = m.getObject();
|
||||
if (obj instanceof Map) {
|
||||
Map<String, Object> dataMap = (Map<String, Object>) obj;
|
||||
String name = (String) dataMap.get("name");
|
||||
|
||||
if (name != null) {
|
||||
// 截取显示名称(最多7个字符)
|
||||
String displayName = name.length() > 7 ? name.substring(0, 7) + "..." :
|
||||
name;
|
||||
boolean isSelected = m.equals(marker);
|
||||
|
||||
// 使用 getMarkerIconWithText 创建带文字的图标
|
||||
BitmapDescriptor icon = getMarkerIconWithText(mContext, displayName,
|
||||
isSelected);
|
||||
m.setIcon(icon);
|
||||
} else {
|
||||
// 如果没有 name,降级到直接设置图标
|
||||
m.setIcon(BitmapDescriptorFactory.fromResource(m.equals(marker) ?
|
||||
R.drawable.ic_marker : R.drawable.ic_un_marker));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1281,13 +1318,12 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
tv.setPadding(dp2px(15), dp2px(12), dp2px(15), dp2px(12));
|
||||
tv.setGravity(Gravity.CENTER);
|
||||
if (isHighlight) {
|
||||
tv.setTextColor(Color.WHITE);
|
||||
// 顶部圆角绿色背景
|
||||
tv.setBackground(getTopRoundedDrawable(Color.parseColor("#27AE60"), 12));
|
||||
} else {
|
||||
tv.setTextColor(Color.parseColor("#666666"));
|
||||
tv.setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
tv.setTextColor(Color.parseColor(isHighlight ? "#ffffffff" : "#ffc9cdd4"));
|
||||
return tv;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFFFFF" />
|
||||
<corners
|
||||
android:topLeftRadius="16dp"
|
||||
android:topRightRadius="16dp"
|
||||
android:topLeftRadius="24dp"
|
||||
android:topRightRadius="24dp"
|
||||
android:bottomLeftRadius="0dp"
|
||||
android:bottomRightRadius="0dp" />
|
||||
</shape>
|
||||
Reference in New Issue
Block a user