Ich habe MapView in AlertDialogBuilder erstellt.MapView in AlertDialog.Builder zeigt zu dunkel
aber wenn die Kartenshow zu dunkel ist und es schwer zu sehen ist ,. kann mir jemand helfen, dieses problem zu lösen?
Ich will nur die Karte ist normal, wie wenn wir die Karte an Aktivität oder Fragment zeigen
hier Code meiner Tätigkeit ist:
private void showCustomAlert(String param){
LayoutInflater inflater = getLayoutInflater();
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.customDialog));
AlertDialog alertDialog = builder.create();
switch (param){
... //other case code whith break point
case "String Param" :
final View rootMV = inflater.inflate(R.layout.custom_alert_maps, null);
alertDialog.setView(rootMV);
MapView mV = rootMV.findViewById(R.id.my_mv_id);
mV.onCreate(alertDialog.onSaveInstanceState());
mV.onResume();
mV.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
LatLng myll = new LatLng(-0.998812,109.784933);
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(myll)
.zoom(18)
.build();
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
googleMap.setMyLocationEnabled(true);
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
googleMap.addMarker(new MarkerOptions().position(myll).title("Place Name"));
try {
MapsInitializer.initialize(getBaseContext());
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
} catch (Exception e) {
e.printStackTrace();
}
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
googleMap.getUiSettings().setZoomControlsEnabled(true);
}
});
alertDialog.show();
break;
}
}
hier ist meine benutzerdefinierte Layout-Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/tv_title_view_maps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textStyle="bold"
android:textAlignment="center"
android:textSize="18sp"
android:textColor="@color/colorAccent"
android:text="Location"/>
<com.google.android.gms.maps.MapView
android:id="@+id/my_mv_id"
android:layout_width="match_parent"
android:layout_height="380dp"
android:layout_below="@+id/tv_title_view_maps"
android:layout_margin="6dp"
style="@style/customDialog"/>
</RelativeLayout>
und hier ist meine benutzerdefinierte Art:
<style name="customDialog" parent="ThemeOverlay.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
und hier ist das Ergebnis: MapView too dark
Vielen Dank im Voraus
Ich denke, man sollte den customDialog Stil auf den RelativeLayout, nicht der MapView zuweisen. – Ridcully
mein Dank @Ridcully, ich arbeite – Habiburrahman