对于web移动端bug总结-微信,uc,ios,andriod,华为,魅族感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解移动端webui,并且为您提供关于Andriodarcgis保存Ma
对于web移动端bug总结-微信,uc,ios,andriod,华为,魅族感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解移动端web ui,并且为您提供关于Andriod arcgis保存Mapview为图片的实例代码、andriod eclipse 基础,新建 andriod project 无法找到 apk 文件、Andriod for webService、Andriod React Native 样式表中可用样式属性的宝贵知识。
本文目录一览:- web移动端bug总结-微信,uc,ios,andriod,华为,魅族(移动端web ui)
- Andriod arcgis保存Mapview为图片的实例代码
- andriod eclipse 基础,新建 andriod project 无法找到 apk 文件
- Andriod for webService
- Andriod React Native 样式表中可用样式属性
web移动端bug总结-微信,uc,ios,andriod,华为,魅族(移动端web ui)
1,关于ios8以下页面出界的情况
解决方案:
var ScrollFix = function(elem) {
// Variables to track inputs
var startY, startTopScroll;
elem = elem || document.querySelector(elem);
// If there is no element, then do nothing
if(!elem)
return;
// Handle the start of interactions
elem.addEventListener(''touchstart'', function(event){
startY = event.touches[0].pageY;
startTopScroll = elem.scrollTop;
if(startTopScroll <= 0)
elem.scrollTop = 1;
if(startTopScroll + elem.offsetHeight >= elem.scrollHeight)
elem.scrollTop = elem.scrollHeight - elem.offsetHeight - 1;
}, false);
};
2,pc端浏览器移动端web页面的时候,禁止滑轮滚动
function noMouseWheel() {
''use strict'';
$(document).on(''mousewheel DOMMouseScroll'', function (e) {
var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || // chrome & ie
(e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); // firefox
if (delta > 0) {
// 向上滚
return false;
} else if (delta < 0) {
// 向下滚
return false;
}
});
}
noMouseWheel();
3,移动端表单滑动的时候会有意向不到的bug,解决方案:页面滑动的时候,让键盘收起
demo:
$(''#edit-wrapper'').scroll(function () {
var scrolls = $(this).scrollTop(); //获取当前可视区域距离页面顶端的距离
if (scrolls >= windowTop) { //当B>A时,表示页面在向下滑动
//需要执行的操作
windowTop = scrolls;
var el = document.activeElement;
if (el.nodeName.toLowerCase() == ''input'') {
el.blur();
return;
}
} else { //当B
//需要执行的操作
windowTop = scrolls;
var el = document.activeElement;
if (el.nodeName.toLowerCase() == ''input'') {
el.blur();
return;
}
}
});
4,页面在安卓手机上滑动特别卡:
解决方案:
// 给body 加上 -webkit-overflow-scrolling:touch
// 元素节点 添加:overflow:auto;
5,针对移动端对screen.width,window.width,document.body.clientWidth各个手机不同对表达以及如何兼容各个手机
描述:通过测试发现,手机对window.width支持良好,但是iphone6plus中safrai却有误差,支持screen.width;但是,华为uc浏览器却对screen.width运算有误差,而对docment.body.clientWidth可见宽度获取精确;
解决方法:为了兼容手机宽度尺寸争取,统一使用document.body.clientWidth,获取手机屏幕宽度;高度使用document.body.clientHeight;
6,关于移动端keyup事件的另外一种书写方法以及函数节流问题解决方案
描述:我们会发现pc端会很好的支持keyup事件,但是移动端就对此支持较差;另,用input事件也是可以,但是在这个项目中也会有问题,和项目根据搜索提示不符;这样的话,我们可以就用focus和blur事件处理下;
focus和blur事件如下:
$input.addEventListener(''focus'', function () { //当获得焦点的时候 filter_time(); $destlist.onscroll = function(){ $groupTitle.classList.add(''zHide''); }; }, false); var _str = '''', _now = ''''; var filter_time = function () { var _time = setInterval(filter_staff_from_exist, 100); $input.addEventListener(''blur'', function () { clearInterval(_time); }, false); }; var filter_staff_from_exist = function () { _now = trim($input.value.toLowerCase()); if (_now != '''' && _now != _str) { // search(trim($input.value.toLowerCase())); throttle(queryData,null,100,_now,50); //调用函数 } if (_now === '''') { cityListShow(); } else { cityListHide(); } _str = _now; };
另外一个问题,就是函数节流的问题,我们会发现当用户输入选择的时候,会不断触发搜索提示判断,但是如果所有数据是ajax请求的话,会增加浏览器负担,影响内存;因此,得处理下搜索判断;
方案:计时器的应用
function queryData(text){ //处理搜索内容
console.log(''搜索:''+text);
search(trim(text.toLowerCase()));
}
// function throttle(fn,context,delay,text){
// clearTimeout(fn.timeoutId);
// fn.timeoutId = setTimeout(function(){
// fn.call(context,text);
// },delay);
// }
function throttle(fn,context,delay,text,mustApplyTime){ //处理计时器及时清除和搜索
clearTimeout(fn.timer); //首先清除计时器
fn._cur = Date.now(); //纪录当前时间
if(!fn._start){ //若函数不是第一次调用,则直接设置_start,即开始时间,为_cur,即此刻的时间;
fn._start = fn._cur;
}
if(fn._start - fn._cur > mustApplyTime){ //当前时间与上一次函数执行的时间做差,与mustApplyTime做比较,若大于必须执行一次函数,
//若小于则重新计算计时器
fn.call(context,text); //改变this对象,获取参数
fn._start = fn._cur;
}else{
fn.timer = setTimeout(function(){
fn.call(context,text); //同上
},delay);
}
}
7,ios10版本以上placeholder的问题;
如果input框中有占位符placeholder的时候,初次点击其它的地方,把值传入到input框的时候,ios10此时placeholder不消失
解决方案:当点击的时候清空placeholder的值,input框获得焦点的时候在写入placeholder的默认值;
Andriod arcgis保存Mapview为图片的实例代码
废话不多说了,直接给大家贴代码了,具体代码如下所述:
/** * 把一个View的对象转换成bitmap */ private Bitmap getViewBitmap(MapView v) { v.clearFocus(); v.setpressed(false); //能画缓存就返回false boolean willNotCache = v.willNotCacheDrawing(); v.setwillNotCacheDrawing(false); int color = v.getDrawingCacheBackgroundColor(); v.setDrawingCacheBackgroundColor(0); if (color != 0) { v.destroyDrawingCache(); } v.buildDrawingCache(); Bitmap cacheBitmap = null; while(cacheBitmap == null){ cacheBitmap = v.getDrawingMapCache(0,v.getWidth(),v.getHeight()); } Bitmap bitmap = Bitmap.createBitmap(cacheBitmap); // Restore the view v.destroyDrawingCache(); v.setwillNotCacheDrawing(willNotCache); v.setDrawingCacheBackgroundColor(color); return bitmap; } public void saveMyBitmap(String bitName,Bitmap mBitmap){ String FileName=this.getInnerSDCardpath() + "/" + bitName + ".png"; ShowMessage(FileName); File f = new File(FileName); try { f.createNewFile(); } catch (IOException e) { // Todo Auto-generated catch block Log.e("在保存"+FileName+"图片时出错:" + e.toString(),"在保存"+FileName+"图片时出错:" + e.toString()); } FileOutputStream fOut = null; try { fOut = new FileOutputStream(f); } catch (FileNotFoundException e) { e.printstacktrace(); } mBitmap.compress(Bitmap.CompressFormat.PNG,100,fOut); try { fOut.flush(); } catch (IOException e) { e.printstacktrace(); } try { fOut.close(); } catch (IOException e) { e.printstacktrace(); } } //缩小 private class ButtonNexitClickListener implements View.OnClickListener { public void onClick(View v) { //ShowMessage("ok1"); Bitmap bitmap=getViewBitmap(mapView); //ShowMessage("ok2"); saveMyBitmap("yl",bitmap); //ShowMessage("ok3"); bitmap.recycle(); ShowMessage("保存成功"); } }
以上所述是小编给大家介绍的Andriod arcgis保存Mapview为图片的实例代码,希望对大家有所帮助!
andriod eclipse 基础,新建 andriod project 无法找到 apk 文件
搭好 eclipse andriod 环境后,可以新建案例工程 (example project) 并且允许调试,但是新建自己的工程不能运行,说找不到 apk 文件。。。这是怎么回事啊Andriod for webService
以前一直都用HttpURLConnection 或 HttpClient 向服务器发布和接收数据。
这次因为项目需求使用 webService 来与服务端交互。
这里主要介绍webService来传递负责对象,传递简单数据可参考其它文章。
需要下载一个 ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar 的包.
final static String SERVICE_NS = "http://service.web.rt.org/"; final static String SERVICE_URL = "http://192.168.2.116:8080/webservice/UserService"; //调用的方法 String methodName = "save";此方法为你要调用服务器端的方法名称 //创建httpTransportSE传输对象 HttpTransportSE ht = new HttpTransportSE(SERVICE_URL); ht.debug = true; //使用soap1.1协议创建Envelop对象 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //实例化SoapObject对象 SoapObject request = new SoapObject(SERVICE_NS,methodName); 这里我们要传递一个User对象给服务器端 封装此User对象 User user1 = new User(); user1.setPassword("123"); user1.setUserID("A662"); user1.setUsername("charles"); 这里的setName 一定要与服务器接收端的参数名一致,否则服务器端无法获得 PropertyInfo property = new PropertyInfo(); property.setName("arg0"); property.setValue(user1); property.setType(User.class); request.addProperty(property); envelope.addMapping(SERVICE_NS,"User",user1.getClass()); envelope.bodyOut = ht; envelope.setoutputSoapObject(request); //将SoapObject对象设置为SoapSerializationEnvelope对象的传出SOAP消息 try{ //调用webService ht.call(null,envelope); if(envelope.getResponse() != null){ SoapObject result = (SoapObject) envelope.bodyIn; System.out.println("result>>>>>>"+result); User user = new User(); SoapObject soapChildsChilds = (SoapObject)result.getProperty(0); user = (User) JsonToBean.json2Bean(soapChildsChilds,User.class);//本人利用反射改写JsonToBean来获取user对象 System.out.println(user); }catch (Exception e) { e.printstacktrace(); }
下面是自己定义的User对象
public class User implements KvmSerializable { private Stringpassword; private StringuserID; private Stringusername; public String getpassword() { return password; } public void setPassword(String password) { this.password = password; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getUserID() { return userID; } public void setUserID(String userID) { this.userID = userID; } @Override public String toString() { // Todo Auto-generated method stub return "username :"+username+"password :"+password+"userID "+userID; } public Object getProperty(int arg0) { switch (arg0) { case 0: return password; case 1: return userID; case 2: return username; } return null; } public int getPropertyCount() { // Todo Auto-generated method stub return 3; } public void getPropertyInfo(int arg0,Hashtable arg1,PropertyInfo arg2) { switch (arg0) { case 0: arg2.type = PropertyInfo.STRING_CLASS; arg2.name = "password";//此处为解析xml标签时使用 注意引号一定不要少 break; case 1: arg2.type = PropertyInfo.STRING_CLASS; arg2.name = "userID"; break; case 2: arg2.type = PropertyInfo.STRING_CLASS; arg2.name = "username"; break; } } public void setProperty(int arg0,Object arg1) { switch (arg0) { case 0: password = arg1.toString(); break; case 1: userID = arg1.toString();; break; case 2: username = arg1.toString();; break; } } }
个人感觉每次都需要实现KvmSerializable接口比较麻烦,目前还没找到比较好的方法来解决这个问题。
Andriod React Native 样式表中可用样式属性
写了这么多篇Android React Native的博文,基本上把复杂的东西都搞定了,接下来来看看一些轻松的东西,和布局有关,就是css样式,那么一个View可以设置哪些css样式呢,是和web中的css样式完全一样呢,还是有所不同呢?其实你只要在样式表中书写一个不存在的样式,就会报一大堆错,提示你该样式不存在,然后提供所有可用的样式给你,如图
下面的样式就是样式表中所有可用的属性。
接下来我们来一一解释一下。不过在这之前,我们还需要解释一下再React中,样式表的几种使用方法。
样式的声明
使用样式
也可以接收一个数组
<View style={[styles.base, styles.background]} />
也可以根据条件来应用样式
假如this.state.active是true,styles.active就会被应用,如果为false,styles.active就不会被应用。
当然也是支持下面的这种写法
接下来来讲讲样式表中的具体属性。
定位
定位分为相对定位和绝对定位,属性名为position,属性值为absolute和relative。
当使用绝对布局时,定位根据屏幕来进行。
var AwesomeProject = React.createClass({ render: function() { return ( <View style={styles.container}> <View style={styles.Box1}/> <View style={styles.Box2}/> <View style={styles.Box3}/> <View style={styles.Box4}/> </View> ); },}); var styles = StyleSheet.create({ container:{ flex:1,backgroundColor:'#ff0'//黄色 },Box1:{ width:50,height:50,backgroundColor:'#f00',//红色 position :'absolute',left:30,//左边距离屏幕左侧30单位 },Box2:{ width:50,backgroundColor:'#0f0',//绿色 position :'absolute',top:30,//上边距离屏幕上侧30单位 },Box3:{ width:50,backgroundColor:'#f0f',//紫色 position :'absolute',right:30,//右边距离屏幕右侧30单位 },Box4:{ width:50,backgroundColor:'#00f',//蓝色 position :'absolute',bottom:30//下边距离屏幕下侧30单位 } });
效果图如下。
当对应的值为负数时,方向与原方向相反,即如果top为-50,则会整个移出到屏幕外(向上移到50个单位)。
那么相对布局又是怎么样的呢
var AwesomeProject = React.createClass({ render: function() { return ( <View style={styles.container}> <View style={styles.Box1}/> </View> ); },//红色 position :'relative',});
效果图
可以看到设置了top和left后,相对于不使用定位的位置向右向下移动了30单位,如果值为负数,也是往相反的方向移到。
但是如果设置了right和bottom后,又会怎么样呢
var styles = StyleSheet.create({ container:{ flex:1,bottom:30,});
其实它的效果就是对应的top和left为负值的情况。距离原来位置的右侧30单位,距离原来位置下侧30单位,即向上向左平移30单位。原来位置就是不使用定位时的位置。如图
默认情况下使用的是相对定位
边框宽度
你可以使用设置所有边框的宽度,也可以设置指定某条边的宽度。
边框颜色
同边框宽度属性,属性值为字符串类型的rgb表示方式
外边距
值得注意的是marginVertical相当于同时设置marginTop和marginBottom,marginHorizontal相当于同时设置marginLeft和marginRight,margin相当于同时设置四个
内边距
背景色
背景色,属性值为字符串类型的rgb表示方式
backgroundColor
边框圆角
宽高
width height
Flex布局相关
相关内容见Flex 布局教程:语法篇和Flex 布局教程:实例篇,个人觉得写得很清晰
字体相关属性
图片相关属性
其中resizeMode 中的三个属性,contain是指无论如何图片都包含在指定区域内,假设设置的宽度高度比图片大,则图片居中显示,否则,图片等比缩小显示
测试代码如下
var AwesomeProject = React.createClass({ render: function() { return ( <View style={styles.container}> <Image source={{uri:'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png'}} style={styles.img}></Image> </View> ); },}); var styles = StyleSheet.create({ container:{ backgroundColor:'#ff0'//黄色 },img:{ flex:1,height:150,resizeMode:"contain" },});
效果图如下图显示
将高度改成50,则进行缩小
cover是指按实际大小进行显示,超出部分进行裁剪,将属性值改成cover之后的效果图如下
stretch是指将图像进行拉伸显示,将属性值改为stretch后的效果如下图所示
图像变换
阴影
关于web移动端bug总结-微信,uc,ios,andriod,华为,魅族和移动端web ui的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Andriod arcgis保存Mapview为图片的实例代码、andriod eclipse 基础,新建 andriod project 无法找到 apk 文件、Andriod for webService、Andriod React Native 样式表中可用样式属性等相关知识的信息别忘了在本站进行查找喔。
本文标签: