android - 在底部工作表和 mapView 之间添加视差效果时隐藏 Google 徽标
问题描述
我正在尝试在底部工作表布局和地图视图之间添加并行效果。但是在扩展底部工作表布局时,谷歌登录地图视图是隐藏的。[谷歌标志被隐藏]
我正在使用以下代码:
布局
<android.support.design.widget.CoordinatorLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Green"
tools:context=".ui.activities.ChooseLocationActivity">
<RelativeLayout
android:id="@+id/map_rlyt"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.koya.android.ui.widget.CollapseBehavior"
app:layout_anchor="@+id/bottom_sheet_layout">
<fragment
android:id="@+id/g_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/category_activity_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/category_search_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/custom_edit_text_margin_top"
android:layout_marginLeft="@dimen/custom_edit_text_margin_left_right"
android:layout_marginRight="@dimen/custom_edit_text_margin_left_right"
android:background="@android:color/transparent">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/ic_back_iv"
android:padding="@dimen/location_activity_back_button_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/ic_back_black"/>
<EditText
android:id="@+id/editTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/custom_edit_text_padding"
android:textColor="@color/black"
android:drawablePadding="8dp"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:drawableLeft="@mipmap/ic_search_gray"
android:textCursorDrawable="@drawable/edit_text_cursor_drawable"
android:drawableRight="@mipmap/ic_close_gray"
android:textSize="@dimen/custom_edit_text_text_size"
android:background="@drawable/drawable_custom_edittext"
/>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
<Button
android:id="@+id/redo_search_in_map_area_button"
style="@style/CategoryChooseButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/category_search_box"
android:layout_centerInParent="true"
android:layout_marginTop="@dimen/fifteen_text_size"
android:animateLayoutChanges="true"
android:paddingEnd="@dimen/redo_search_button_padding"
android:paddingStart="@dimen/redo_search_button_padding"
android:text="@string/redo_search_in_map_area"
android:textAllCaps="false"
android:visibility="gone"
/>
</RelativeLayout>
<include
android:id="@+id/bottom_sheet_layout"
layout="@layout/bottom_sheet"/>
<Button
android:id="@+id/select_location_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="@string/use_selected_location"
android:visibility="gone"
tools:visibility="visible"
style="@style/CategoryChooseButtonStyle"/>
<include android:id="@+id/error_layout"
layout="@layout/error_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
/>
并实现 Coordinatorlayout.Behavior
public class CollapseBehavior<V extends ViewGroup> extends CoordinatorLayout.Behavior<V>{
public CollapseBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, V child, View dependency) {
if (isBottomSheet(dependency)) {
BottomSheetBehavior behavior = ((BottomSheetBehavior) ((CoordinatorLayout.LayoutParams) dependency.getLayoutParams()).getBehavior());
int peekHeight = behavior.getPeekHeight();
// The default peek height is -1, which
// gets resolved to a 16:9 ratio with the parent
final int actualPeek = peekHeight >= 0 ? peekHeight : (int) (((parent.getHeight() * 1.0) / (16.0)) * 9.0);
if (dependency.getTop() >= actualPeek) {
// Only perform translations when the
// view is between "hidden" and "collapsed" states
final int dy = dependency.getTop() - parent.getHeight();
ViewCompat.setTranslationY(child, dy/2);
return true;
}
}
return false;
}
private static boolean isBottomSheet(@NonNull
View view) {
final ViewGroup.LayoutParams lp = view.getLayoutParams();
if (lp instanceof CoordinatorLayout.LayoutParams) {
return ((CoordinatorLayout.LayoutParams) lp)
.getBehavior() instanceof BottomSheetBehavior;
}
return false;
}
}
我在我的应用程序中需要这种类型的滚动-> https://streamable.com/g0tf9
当底页具有视差效果时如何滚动谷歌地图?我将不胜感激!
提前致谢。
解决方案
推荐阅读
- sql - 使用正则表达式提取不在方括号内的字符串模式
- javascript - 如何将excel单个单元格中的数据格式化为正确的列和行?
- android - Android Studio 3.5 在多个设备上运行应用程序
- java - 使用 Google drive api - java sdk - 如何获取按日期过滤的文件修订
- amazon-ec2 - 如何连接到具有防火墙保护的远程数据库
- hash - 当直接打开带有主题标签(锚链接)的网站时不起作用 - 在角度 6 中?
- php - 未验证电子邮件时处理电子邮件验证响应
- json - 将 Ruby 2.4.2 升级到 2.6.3 导致 JSON 错误
- python - MySQLdb connection.close() 在 Python 2.7 中不起作用
- c++ - 使用 std::pow 检查位掩码中的单个位