Android - 布局边框,旧的“寄宿生”仍然可见

问题描述 投票:0回答:1

我有一个约束布局,我添加了一个边框,如下所示:

custom_info_window.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/info_window_boarder"
    >
...
...

info_window_boarder.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF"/>
    <stroke android:width="3dip" android:color="#B1BCBE" />
    <corners android:radius="10dip"/>
    <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

但我仍然看到旧的“寄宿生”(白色方形寄宿生)。我怎么摆脱它?

enter image description here

android android-layout android-xml
1个回答
0
投票

弄清楚了。

我在getInfoContents而不是getInfoWindow中设置了Info Window的东西。

getInfoContents将为您提供默认的白色框。如果你想要像我这样的自定义,你将需要像getInfoWindow那样做所有事情:

     mMap.setInfoWindowAdapter(object : GoogleMap.InfoWindowAdapter {
        override fun getInfoWindow(marker: Marker?): View {
            val row: View = layoutInflater.inflate(R.layout.custom_info_window, null)
            val tvAddress: TextView = row.findViewById(R.id.textView_iw_address)
            val tvTime: TextView = row.findViewById(R.id.textView_iw_time)

            tvAddress.text = marker?.title
            tvTime.text = marker?.snippet

            return row            }

        override fun getInfoContents(marker: Marker?): View? {
            //put in here, if you just want the default info window
            return null
        }
    })
© www.soinside.com 2019 - 2024. All rights reserved.