android - 为什么使用 mapview 看不到 android 小吃吧?
问题描述
我正在使用 Yandex MapKit 的地图。当用户点击地图时,我向他显示搜索结果,添加地标并显示带有位置名称和按钮的小吃栏。
问题
在我的小米设备(小米米 9、android 9)上存在快餐栏,但在未执行某些操作之前它是不可见的。
示例: 点击地图 打开应用程序管理器 通过在应用程序管理器中点击再次打开应用程序
我还可以打开搜索编辑(地图顶部),然后会显示小吃吧。当snackbar不可见时,它存在:我可以点击snackbar按钮半径,按钮的动作将运行!
当我使用android模拟器时没有任何问题(不同API中的Google Pixel:23、28、29 ...)
我的活动 XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/placesMapLayout"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".activities.PlacesMapActivity">
<com.yandex.mapkit.mapview.MapView
android:id="@+id/placesMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/outlinedTextField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxBackgroundColor="@color/white"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_margin="20dp"
android:hint="@null">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchEdit"
android:imeOptions="actionSearch"
android:inputType="text"
app:boxBackgroundColor="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>
Snackbar 创建(Kotlin):
val snackbar = Snackbar.make(placesMapLayout, foundObject.name.toString(), Snackbar.LENGTH_INDEFINITE)
我试图为 mapView 设置 layout_height 以获得活动底部的空白位置。它已经奏效了:screenshot。一键和小吃店可见!但我不想裁剪我的地图。
那么,mapView是否存在问题以及如何解决呢?
解决方案
snackbar.view.post { snackbar.view.requestLayout() }
它帮助了我。
推荐阅读
- python - 用于小型计算的 Python 可扩展并行处理
- javascript - TypeScript 编译器是否存在关于泛型的错误,或者我遗漏了什么?
- firebase - 在 Firebase 实时数据库上进行公共读取访问是否安全?
- angular - Angular 访问 dom 元素
- java - 使用 CriteriaBuilder 的 JPA 计数(*)
- php - 服务器端更改以禁用 Firefox Race Cache with Network (RCWN)?
- .net - grpc 服务可以托管在 .Net Framework 或 .Net Standard 中吗
- css - 如何为 4 个项目增加这个 css 动画?
- gnuplot - 在 GnuPlot 中将两个不同大小的图合二为一
- python-3.x - Python unittest.mock google storage - 如何实现 exceptions.NotFound 作为副作用