在百度地图上实现添加自定义的view,但是却发现LayoutInflater.from().inflate()不能加载自定义的view,表现在不执行onDraw()方法。
解决办法其实很巧妙,只需要将xml中自定义view的宽高设定为固定值即可:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.example.baidudemo.myView
android:id="@+id/myview"
android:layout_width="200dp"
android:layout_height="200dp" />
</RelativeLayout>
这样即可。