【问题标题】:Bottom sheet not working with google map底页不适用于谷歌地图
【发布时间】:2018-07-18 13:14:11
【问题描述】:

当我尝试通过交换关闭此 BottomSheet 时,地图正在移动

<android.support.design.widget.CoordinatorLayout 
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"
tools:context=".MapsActivity">

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="40dp" />

<LinearLayout
    android:id="@+id/bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:background="#FFFFFF"
    android:orientation="vertical"
    app:behavior_hideable="false"
    app:behavior_peekHeight="40dp"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="@color/colorAccent"
        android:gravity="center"
        android:textColor="@android:color/white" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:textColor="@android:color/white" />

</LinearLayout>

我必须做什么?我想要谷歌地图。 我尝试设置 OnclickListener,但我只能在底部使用 BottomSheet。

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}

这是 onCreate()

【问题讨论】:

标签: java android


【解决方案1】:

看起来类似于my answer here

尝试将nestedScrollingEnabled="true" 添加到底部工作表布局中:

 <androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:nestedScrollingEnabled="true"
    app:behavior_hideable="true"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

【讨论】:

    猜你喜欢
    • 2020-12-04
    • 1970-01-01
    • 2014-03-01
    • 2017-01-02
    • 1970-01-01
    • 1970-01-01
    • 2020-05-25
    • 2018-01-02
    • 2015-02-23
    相关资源
    最近更新 更多