【问题标题】:TextView on a map fragment does not follow its movement on dragging地图片段上的 TextView 在拖动时不跟随其移动
【发布时间】:2020-12-15 18:00:22
【问题描述】:

我在谷歌地图片段上定位TextView,如下所示:

private fun putTextView() {
    val layout : FrameLayout = findViewById(R.id.frameLayout)
    val textView : TextView = TextView(this)
    textView.textSize = 14F
    textView.text = " some text "
    textView.setTextColor(Color.BLACK)
    textView.setPaddingRelative(100,100,0,0)
    layout.addView(textView)
}

它确实出现在我希望它出现的位置,但是当我在地图上拖动时,TextView 不会跟随移动,而是停留在屏幕上的同一位置。如何让它在我拖动时跟随地图的移动?

【问题讨论】:

    标签: android kotlin google-maps-android-api-2


    【解决方案1】:

    听起来您真的只想要一个带有文本的Marker,而不是TextView。请参阅 android-maps-utils 库中的 IconGenerator 功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-26
      • 2021-12-06
      • 1970-01-01
      • 2018-06-27
      • 1970-01-01
      相关资源
      最近更新 更多