我正在尝试在对话框窗口中显示谷歌地图。对于此对话框,我使用以下代码行:
final Dialog dialog = new Dialog(SetProfileOnlineActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(false);
dialog.setContentView(R.layout.pick_location_layout);
Window w = dialog.getWindow();
w.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
dialog.show();
pick_location_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.maps.MapView
android:id="@+id/mapview"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/myLl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<LinearLayout
android:id="@+id/ll_map_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@color/white"
android:orientation="horizontal"
>
<EditText
android:id="@+id/et_search_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Search"
android:padding="8dp"
android:layout_weight="1"
android:textColor="@color/black"
android:textSize="18sp"
android:maxLines="1"
android:background="@android:color/transparent"
/>
<ImageButton
android:id="@+id/ib_search_map"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="fitCenter"
android:src="@drawable/search"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/myLl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent">
<Button
android:id="@+id/btn_map_cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/red"
android:text="Cancel"
android:textColor="@color/white"
android:textSize="@dimen/_18sdp" />
<Button
android:id="@+id/btn_map_ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/green"
android:text="Ok"
android:textColor="@color/white"
android:textSize="@dimen/_18sdp" />
</LinearLayout>
<Button
android:id="@+id/btn_switch_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="Switch View"
app:layout_constraintBottom_toTopOf="@+id/myLl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
现在我的问题是我的地图显示更暗。我也在显示完美显示的对话框中显示edittext但地图只是显示较暗的组件,如图所示。那么,有没有办法让mapview像其他组件一样更亮?
答案 0 :(得分:3)
更新MapView
mapView
中dialog
的解决方案是删除这样的背景暗淡(针对您的代码调整,只需在dialog.show()
之前粘贴):
w.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
不好的部分是我在5 year old question
中找到了这个解决方案上一个回答
我刚刚查看了“较新的地图”解决方案(read more here):
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
app:mapType="normal"
android:layout_width="match_parent"
android:layout_height="match_parent" />
它显示明亮的--image was here--