我已成功使用包裹在MapView中的协调员布局成功获取小吃店布局。地图视图成功滑出以便为小吃店留出空间,但是,一旦小吃店走了,视图保持不动,并留下白色酒吧,小吃店将出现在那里。我怎样才能解决这个问题?我目前正在应用下列代码在地图视图中的行为:布局视图在小吃店出现时出现协调员视图
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
return true;
}
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
// we only want to trigger the change
// only when the changes is from a snackbar
return dependency instanceof Snackbar.SnackbarLayout;
}
和我的片段看法是这样的:
<android.support.design.widget.CoordinatorLayout
android:id="@+id/places_coordinator_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.adamshort.canieatthis.FloatingActionButtonBehaviour"/>
</android.support.design.widget.CoordinatorLayout>
我试着摸索,但无论我在寻找对于错误的事情或我没有人有类似的问题。我已经看到了我发布并在各种教程和视频中成功运行的行为代码,但它在地图视图中表现不佳。有什么想法吗?
您应该添加“应用程序:layout_behavior =” com.adamshort.canieatthis.FloatingActionButtonBehaviour”你的漂浮动作按钮......而不是MapView的 – W0rmH0le
@GuilhermeP这是一个自定义行为模仿所发生的浮动按钮。它的全部要点是将自定义行为应用到其他视图,这就是我给它的名称,因为它会复制FAB。 –
对不起...你对...忘记它... – W0rmH0le