【发布时间】:2016-05-16 22:53:26
【问题描述】:
我已经成功地使用围绕片段中 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>
我尝试过四处搜索,但要么我在寻找错误的东西,要么我没有人遇到过类似的问题。我已经看到我在各种教程和视频中发布并成功运行的行为代码,但它在地图视图中表现不佳。有什么想法吗?
【问题讨论】:
-
您应该将“app:layout_behavior="com.adamshort.canieatthis.FloatingActionButtonBehaviour" 添加到浮动操作按钮...而不是 MapView
-
@GuilhermeP 这是一种模仿浮动按钮发生的自定义行为。它的全部意义在于将自定义行为应用于其他视图,这只是我给它的名称,因为它将复制 FAB。
-
对不起...你对...算了...
标签: android android-fragments android-mapview android-snackbar