分类:C#、Android、VS2015、百度地图应用; 创建日期:2016-02-04

一、简介

简介:介绍开关手势功能和显示隐藏UI控件

详述:

(1)地图操作开关:平移、缩放、双击放大、双指操作(旋转度和俯视度);

(2)控件显示开关:显示/隐藏缩放按钮;

(3)指南针位置控制:显示在地图左上角或者右上角(仅举例),开发者可据实际情况任意改变位置;

(4)底图标注开关:控制显示/隐藏底图POI,隐藏POI可得到仅显示道路信息的地图

运行截图

在x86模拟器中的运行效果如下:

二、设计步骤

在上一节例子的基础上,只需要再增加下面的步骤即可。

1、添加demo07_uisetting.axml文件

在layout文件夹下添加该文件,将其改为下面的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal" > <CheckBox
android:id="@+id/zoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="缩放" /> <CheckBox
android:id="@+id/scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="平移" />
</LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal" > <CheckBox
android:id="@+id/rotate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="旋转" /> <CheckBox
android:id="@+id/overlook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="俯视" />
</LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal" > <CheckBox
android:id="@+id/compass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="开启指南针" /> <CheckBox
android:id="@+id/mappoi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="底图标注" /> </LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal" > <CheckBox
android:id="@+id/allGesture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="false"
android:text="禁用所有手势" /> <CheckBox
android:id="@+id/setPadding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="设置Padding" /> </LinearLayout> <com.baidu.mapapi.map.TextureMapView
android:id="@+id/bmapView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true" /> </LinearLayout>

2、添加Demo07UISetting.cs文件

在SrcSdkDemos文件夹下添加该文件,然后将其内容改为下面的代码:

using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Widget;
using Com.Baidu.Mapapi.Map; namespace BdMapV371Demos.SrcSdkDemos
{
/// <summary>
/// 演示地图UI控制功能
/// </summary>
[Activity(ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden,
Label = "@string/demo_name_ui",
ScreenOrientation = ScreenOrientation.Sensor)]
public class Demo07UISetting : Activity
{
private TextureMapView mMapView; protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.demo07_uisetting); mMapView = FindViewById<TextureMapView>(Resource.Id.bmapView);
BaiduMap mBaiduMap = mMapView.Map;
mBaiduMap.SetMapStatus(MapStatusUpdateFactory.NewLatLng(MainActivity.HeNanUniversity)); UiSettings mUiSettings = mBaiduMap.UiSettings; MapStatus ms = new MapStatus.Builder().Overlook(-).Build();
MapStatusUpdate u = MapStatusUpdateFactory.NewMapStatus(ms);
mBaiduMap.AnimateMapStatus(u, ); var zoom= FindViewById<CheckBox>(Resource.Id.zoom);
zoom.CheckedChange += (s,e)=>
{
//是否启用缩放手势
mUiSettings.ZoomGesturesEnabled = e.IsChecked;
}; var scroll = FindViewById<CheckBox>(Resource.Id.scroll);
scroll.CheckedChange += (s, e) =>
{
//是否启用平移手势
mUiSettings.ScrollGesturesEnabled = e.IsChecked;
}; var rotate = FindViewById<CheckBox>(Resource.Id.rotate);
rotate.CheckedChange += (s, e) =>
{
//是否启用旋转手势
mUiSettings.RotateGesturesEnabled = e.IsChecked;
}; var overlook = FindViewById<CheckBox>(Resource.Id.overlook);
overlook.CheckedChange += (s, e) =>
{
//是否启用俯视手势
mUiSettings.OverlookingGesturesEnabled = e.IsChecked;
}; var compass = FindViewById<CheckBox>(Resource.Id.compass);
compass.CheckedChange += (s, e) =>
{
//是否启用指南针图层
mUiSettings.CompassEnabled = e.IsChecked;
}; var mappoi = FindViewById<CheckBox>(Resource.Id.mappoi);
mappoi.CheckedChange += (s, e) =>
{
//是否显示底图默认标注
mBaiduMap.ShowMapPoi(e.IsChecked);
}; } protected override void OnPause()
{
mMapView.OnPause();
base.OnPause();
} protected override void OnResume()
{
mMapView.OnResume();
base.OnResume();
} protected override void OnDestroy()
{
mMapView.OnDestroy();
base.OnDestroy();
}
}
}

3、修改MainActivity.cs文件

在MainActivity.cs文件的demos字段定义中,去掉【示例7】下面的注释。

运行观察结果。

【Android】3.7 UI控制功能的更多相关文章

  1. Android异步更新UI的四种方式

    Android异步更新UI的四种方式 2015-09-06 09:23 segmentfault 字号:T | T 大家都知道由于性能要求,android要求只能在UI线程中更新UI,要想在其他线程中 ...

  2. Android开发之UI更新交互机制与实例解析

    android开发过程中,经常需要更新UI的状态和文案等.这是就需要对UI进行 更新.在android中更新UI一般有三种方法,handler机制.RunOnUiThread方法以及AsyncTask ...

  3. ReactNative Android之原生UI组件动态addView不显示问题解决

    ReactNative Android之原生UI组件动态addView不显示问题解决 版权声明:本文为博主原创文章,未经博主允许不得转载. 转载请表明出处:http://www.cnblogs.com ...

  4. Android开发 ---基本UI组件4:拖动事件、评分进度条、圆圈式进度条、进度条控制

    Android开发 ---基本UI组件4 1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding=" ...

  5. Android开发 ---基本UI组件3:单选按钮、多选按钮、下拉列表、提交按钮、重置按钮、取消按钮

    Android开发 ---基本UI组件2 1.activity_main.xml 描述: 定义一个用户注册按钮 <?xml version="1.0" encoding=&q ...

  6. Android开发 ---基本UI组件2:图像按钮、单选按钮监听、多选按钮监听、开关

    Android开发 ---基本UI组件2 1.activity_main.xml 描述: 定义一个按钮 <?xml version="1.0" encoding=" ...

  7. android线程控制UI更新(Handler 、post()、postDelayed()、postAtTime)

    依照以下的理解就是handler与ui线程有一定的关联能够由于更新界面仅仅能在主线程中全部更新界面的地方能够在接受消息的handleMessage那里还有更新界面能够在handler.port(new ...

  8. Android多线程更新UI的方式

    Android下,对于耗时的操作要放到子线程中,要不然会残生ANR,本次我们就来学习一下Android多线程更新UI的方式. 首先我们来认识一下anr: anr:application not rep ...

  9. Android 线程更新UI报错 : Can't create handler inside thread that has not called Looper.prepare()

    MainActivity中有一个按钮,绑定了save方法 public void save(View view) { String title = titleText.getText().toStri ...

随机推荐

  1. Lisp分配给保护的符号…

    在进行调试时,弹出"分配给保护的符号:pf,是否进入中断循环",但似乎不会影响结果. 明经版主解译说是:给受保护的符号重新赋值了,所以有此提示,此提示仅在打开了vlide 编辑器才 ...

  2. iOS app集成支付宝支付流程及后台php订单签名处理

    iOS app集成支付宝支付流程 1: 开通支付宝商户 由公司去支付宝 https://b.alipay.com/order/serviceIndex.htm 签约支付宝开通支付宝商家: 2:商户支付 ...

  3. H面试(23):求子数组最大和

    题目描述: 输入一个整形数组,数组里有正数也有负数. 数组中连续的一个或多个整数组成一个子数组,每个子数组都有一个和. 求所有子数组的和的最大值.要求时间复杂度为O(n). 例如输入的数组为1, -2 ...

  4. Linux下启动eclipse报错

    A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be avail   Java RunTime Environm ...

  5. 算法笔记_197:历届试题 带分数(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 问题描述 100 可以表示为带分数的形式:100 = 3 + 69258 / 714. 还可以表示为:100 = 82 + 3546 / 197. ...

  6. Servlet介绍(一)

    Servlet介绍(一) Servlet是一个执行在webserver上的小的Java程序,它通过接收和响应webclient的请求.在tomcatserver中有已经帮我们实现好了Servlet接口 ...

  7. git的color configura

    git color的配置 Git多颜色输出 Git默认的输出是单一颜色的,不仅不够美观,也不容易阅读.实际上,Git本身就支持用多种颜色来显示其输出的信息,只需在命令行中运行以下命令来修改git的设置 ...

  8. 关于DES加密中的 DESede/CBC/PKCS5Padding

    今天看到一段3DES加密算法的代码,用的参数是DESede/CBC/PKCS5Padding,感觉比较陌生,于是学习了一下. 遇到的java代码如下: Cipher cipher=Cipher.get ...

  9. Unix 网络编程 读书笔记2

    第三章 套接字编程简介 每一个 Socket 都用一个半相关描述:{协议,本地地址,本地端口}一个完整的 Socket 则用一个相关描述{协议,本地地址,本地端口,远程地址,远程端口}每一个 Sock ...

  10. window下rabbitmq的配置问题

    最近项目想用个MQ来做业务分离,看了市面上众多产品,最后选了rabbitmq,理由很简单,对window的支持很到位(其实是公司的系列产品都是.net的). 安装方法什么的就不说了,直接到官网下载双击 ...