无法让我的 Google 地图 supportMapFragment 具有 width/height 到 "match_parent" 的布局
Can't get my Google Maps supportMapFragment to have layout width/height to "match_parent"
我似乎无法让我的 Google 地图在布局 width/height 中保持在 "match_parent"。
以下是我希望它保留的方式:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.myname.myapp.MapsActivity" >
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.constraint.ConstraintLayout>
一旦我在 Android Studio 文本中单击 "preview" 或 "design",就会发生以下情况:
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="395dp"
android:layout_height="643dp"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp"
代码只是转换成上面的,我不需要这个。上面的代码不适合整个屏幕,左边的所有角落都有很多白色 space。看起来像下面这样:
即使我将视图限制在屏幕上,它也是这么大,所以四面八方仍然会有这个白色space。
如果没有 "fixing" 本身,如何在 layout_width 和 layout_height 上实现 "match_parent"?
尝试给出以下布局:
<android.support.constraint.ConstraintLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.example.myname.myapp.MapsActivity" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</android.support.constraint.ConstraintLayout>
我似乎无法让我的 Google 地图在布局 width/height 中保持在 "match_parent"。
以下是我希望它保留的方式:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.myname.myapp.MapsActivity" >
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.constraint.ConstraintLayout>
一旦我在 Android Studio 文本中单击 "preview" 或 "design",就会发生以下情况:
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="395dp"
android:layout_height="643dp"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp"
代码只是转换成上面的,我不需要这个。上面的代码不适合整个屏幕,左边的所有角落都有很多白色 space。看起来像下面这样:
即使我将视图限制在屏幕上,它也是这么大,所以四面八方仍然会有这个白色space。
如果没有 "fixing" 本身,如何在 layout_width 和 layout_height 上实现 "match_parent"?
尝试给出以下布局:
<android.support.constraint.ConstraintLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.example.myname.myapp.MapsActivity" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</android.support.constraint.ConstraintLayout>