Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

RoseNameElune/SweeperMap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

SweeperMap

扫地机器人地图的自定义View,支持类似于百度地图的手势缩放功能。

地图

##使用方式

  1. 引入XML布局
<com.xxx.xxx.AreaRoomView
 android:id="@+id/area_view"
 android:layout_width="match_parent"
 android:layout_height="300dp"
 android:background="@color/white" />
  1. 设置数据
AreaRoomView areaRoom = findViewById(R.id.area_view);
List<AreaBean> areaBeans = new ArrayList<>();
//AreaBean对应的参数为,坐标点的id,x坐标,y坐标,障碍物标识符(0无障碍物,1有障碍物)
areaBeans.add(new AreaBean(1,1,1,1));
areaBeans.add(new AreaBean(2,1,2,1));
areaBeans.add(new AreaBean(3,2,2,1));
//设置数据,true为向地图里追加,false为刷新地图从头开始追加数据
areaRoom.setDatas(areaBeans, true);
  1. 清除数据
areaRoom.clear();

备注: 附上底部布局

<LinearLayout
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:gravity="center_vertical|right"
	android:background="@color/white"
	android:orientation="horizontal">
	<View
		android:layout_width="10dp"
		android:layout_height="10dp"
		android:background="@drawable/shape_blue_point"/>
	<TextView
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_marginLeft="5dp"
		android:layout_marginRight="11dp"
		android:text="机器人"/>
	<View
		android:layout_width="10dp"
		android:layout_height="10dp"
		android:background="@drawable/shape_yellow_point"/>
	<TextView
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_marginLeft="5dp"
		android:layout_marginRight="11dp"
		android:text="已打扫"/>
	<View
		android:layout_width="10dp"
		android:layout_height="10dp"
		android:background="@drawable/shape_empty_point"/>
	<TextView
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_marginLeft="5dp"
		android:layout_marginRight="11dp"
		android:text="未打扫"/>
	<View
		android:layout_width="10dp"
		android:layout_height="10dp"
		android:background="@drawable/shape_gray_point"
		android:visibility="gone"/>
	<TextView
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_marginLeft="5dp"
		android:layout_marginRight="10dp"
		android:text="障碍物"
		android:visibility="gone"/>
</LinearLayout>

About

扫地机器人地图的自定义View

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%

AltStyle によって変換されたページ (->オリジナル) /