79501903

Date: 2025-03-11 19:28:39
Score: 1
Natty:
Report link

To retrieve the view with the tag GoogleMapCompass in Kotlin, similar to the Java solution, you can adjust the position by modifying the rules of the RelativeLayout.

Here is an example where the button is positioned 50 pixels from the right and 150 pixels from the bottom:

val compassButton = (supportFragmentManager
    .findFragmentById(R.id.map) as SupportMapFragment)
    .requireView()
    .findViewWithTag<View>("GoogleMapCompass");

val rlp = compassButton.layoutParams as RelativeLayout.LayoutParams
rlp.addRule(RelativeLayout.ALIGN_PARENT_END)
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM)
rlp.removeRule(RelativeLayout.ALIGN_PARENT_START)
rlp.removeRule(RelativeLayout.ALIGN_PARENT_TOP)
rlp.bottomMargin = 150
rlp.rightMargin = 50

Screenshot of Google Map compass at bottom right position

For further customizations of the compass, you will need to create your own implementation.

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Mathis