android - 如果在消失模式下准备好,谷歌地图 v2 就会消失
问题描述
我在 mapFragment 视图中准备的 mapFragment 视图有问题visibility=View.GONE
在准备(getMapAsync
调用)visibility=View.VISIBLE
状态时它可以正常工作,但如果在准备时它会变为空白GONE
在mapFragment
a 中查看ScrollView
(它是较长列表的一部分),并且对滚动处理进行了一些小的调整,它可以完美地工作。
我有一个longClickListener
定义来捕捉 a 的 lat/lng 对,当地图以模式longClick
准备时,这工作正常VISIBLE
,但是当它以GONE
模式准备时,(空白地图)给我 0.0,0.0 lat/lng 结果,这告诉我那是地图不“存在”,(它不是导致这种行为的任何图形抽搐)。
下面是在VISIBLE
模式下准备的地图
即使在什么时候准备好地图也不应该出现GONE
,还是我需要做一些其他的伎俩。
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/register_card_linear_layout_compat_common_selections"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible" <--- toggle to `gone` here cause map to not appear when made visible programmatically
tools:visibility="visible"
android:orientation="vertical">
...
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/register_card_map_fragment"
android:name="no.norva24.mslam.ui.fragments.customizations.ScrollableMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:context=".ui.fragments.RegisterFragment" />
地图在里面准备的地方onViewCreated
mapFragment?.getMapAsync {_googleMap->
Log.i(TAG, "onViewCreated: mapFragment getMapAsync _googleMap =$_googleMap")
_googleMap?.let {safeGoogleMap->
googleMap=safeGoogleMap
LogCat 告诉我,即使地图处于状态,也会getMapAsync
以有效的方式调用..._googleMap
GONE
解决方案
推荐阅读
- reactjs - React-MobX 错误:'decorators' 插件需要一个 'decoratorsBeforeExport' 选项,其值必须是布尔值
- javascript - 将 react-router 链接包装在 html 按钮中作为提交选项
- python - ffmpy 使用文件列表连接多个文件
- java - Tomcat 8 JNDI 和 Oracle 使用 Oracle Wallet
- amazon-web-services - 是否有查找 DynamoDB 查询消耗的 RCU 数量?
- delphi - 如何使用 Delphi DBExpress 监听 Firebird 事件
- powershell - 在退出脚本之前等待 cmdlet 终止
- java - 如何使用 Jersey (JAX-RS) 向 NTLM 认证服务器发出简单的 POST 请求
- jdbc - 可以从 jdbc 连接运行 DB2 命令吗
- julia - 如何使用 Plots.jl 在 Julia 中缩放绘图