【问题标题】:Android - layout border, old "boarder" still visibleAndroid - 布局边框,旧的“边界”仍然可见
【发布时间】:2019-03-03 20:43:45
【问题描述】:

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

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>

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

【问题讨论】:

    标签: android android-layout android-xml


    【解决方案1】:

    想通了。

    我在getInfoContents 而不是getInfoWindow 中设置信息窗口。

    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
            }
        })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-09
      • 1970-01-01
      • 1970-01-01
      • 2012-03-23
      相关资源
      最近更新 更多