首页 文章 精选 留言 我的

精选列表

搜索[网站开发],共10000篇文章
优秀的个人博客,低调大师

Android UI开发第二十篇——仿launcher的左右滑动

在论坛里,经常看到有人问如何实现UC或墨迹天气那样的拖动效果。其实大部分的实现都是参考了Launcher里的Workspace这个类。今天又见问起,特分享一下曾经的用到的部分。先看一下效果图: 第一个视图 滑动过程中 第二个视图 本文转自xyz_lmn51CTO博客,原文链接:http://blog.51cto.com/xyzlmn/817129,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android开发之解决APP启动白屏或者黑屏闪现的问题

在做搜芽的过程中,发现那个外包人缘做的不行,由于启动的时候会停顿,然后白屏一会,联想到几个月前我在我的三僚企业通信软件里面拉起9K-Mail的时候也会黑屏,所以决定学习一下。解决一下。这不,万能的网络还是很实用的。 在这里总结一下。 (參考及转载:http://www.2cto.com/kf/201409/339293.html) 欢迎页启动的线程由于请求和处理的数据量过大而,导致欢迎页在出现之前界面上会有一个短暂的白色闪屏停留。当然白色闪屏的停留是由于 application 的主题样式android:theme=@style/AppTheme 使用了 Theme.Light 题导致的,Light 样式的 windowBackground、colorBackground、colorForeground 等属性的值均为 light 也就是白色偏亮,所以才会出现白色闪屏。以下是我的 APP 出现白色闪屏时样式引用的代码: 1 <style name= "AppTheme" parent= "android:Theme.Light" type= "text/css" ><br><br> </style> 简单的改动后。闪屏颜色为黑色。代码例如以下: 1 <style name= "AppTheme" parent= "android:style/Theme.Black.NoTitleBar.Fullscreen" type= "text/css" > </style> 代码改动后引用的样式为黑色主题,但欢迎页仍然会有黑色闪屏短暂的停留。继续进行改动,设置透明属性为 true。代码例如以下: 1 <style name= "AppTheme" parent= "android:style/Theme.Black.NoTitleBar.Fullscreen" type= "text/css" ><item name=android:windowIsTranslucent> true </item></style> 经过这次的改动之后黑色闪屏现象消失了,终于达到了自己理想的效果。最后,经过查阅资料发现已经有人总结和处理过这类问题了,而且给出了优缺点的分析,我在这里以我的理解对其进行引用。 原来避免黑色闪屏有2种方法,分别为:1.为 Theme 设置背景图;2.为 Theme 设置透明属性。显然我採用的是另外一种方式,先分别看看这2种方式所引用的代码: 1 <!-- 为 Theme 设置背景图 --><style name= "AppTheme" parent= "android:style/Theme.Black.NoTitleBar.Fullscreen" type= "text/css" ><item name=android:windowBackground> @drawable /splash_bg</item></style> 1 <!-- 为 Theme 设置透明属性 --><style name= "AppTheme" parent= "android:style/Theme.Black.NoTitleBar.Fullscreen" type= "text/css" ><item name=android:windowIsTranslucent> true </item></style> 上面的2种 Theme 中,为 Theme 设置背景图后程序在启动的时候,会首先显示这张图,避免发生黑屏;为 Theme 设置透明属性,程序启动后不会黑屏而是透明。等到界面初始化完毕后才一次性显示出来。以下是两种方式的优缺点: 为 Theme 设置背景图 给人程序启动快的感觉,界面先显示背景图。然后再刷新其它界面控件。刷新不同步。 为 Theme 设置透明属性 给人程序启动慢的感觉,界面会一次性刷出来,刷新同步。可是问题有出现了,原先在配置了activity的切换动画效果。设置完android:windowIsTranslucent=true之后切换动画失效了。临时我也不知道android系统的theme属性之间关系的错综复杂,继承来继承去的。 。。为什么会出现这样的问题。只是还好无意间找到了解决的方法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 <style name= "AppTheme" parent= "AppBaseTheme" type= "text/css" ><!-- <item name=android:windowAnimationStyle> @style /Animation.Activity.Style</item> --> <item name=android:windowAnimationStyle> @style /Animation.Activity.Translucent.Style</item> <item name=android:windowBackground> @android :color/transparent</item> <item name=android:windowIsTranslucent> true </item></style><style name= "Animation.Activity.Style" parent= "@android:style/Animation.Activity" type= "text/css" ><item name=android:activityOpenEnterAnimation> @anim /base_slide_right_in</item> <item name=android:activityOpenExitAnimation> @anim /base_stay_orig</item> <item name=android:activityCloseEnterAnimation> @anim /base_stay_orig</item> <item name=android:activityCloseExitAnimation> @anim /base_slide_right_out</item> <item name=android:taskOpenEnterAnimation> @anim /base_slide_right_in</item> <item name=android:taskOpenExitAnimation> @anim /base_stay_orig</item> <item name=android:taskCloseEnterAnimation> @anim /base_stay_orig</item> <item name=android:taskCloseExitAnimation> @anim /base_slide_right_out</item> <item name=android:taskToFrontEnterAnimation> @anim /base_slide_right_in</item> <item name=android:taskToFrontExitAnimation> @anim /base_stay_orig</item> <item name=android:taskToBackEnterAnimation> @anim /base_stay_orig</item> <item name=android:taskToBackExitAnimation> @anim /base_slide_right_out</item></style><style name= "Animation.Activity.Translucent.Style" parent= "@android:style/Animation.Translucent" type= "text/css" ><item name=android:windowEnterAnimation> @anim /base_slide_right_in</item> <item name=android:windowExitAnimation> @anim /base_slide_right_out</item></style> 配置style继承的parent为 1 2 <style name= "Animation.Activity.Translucent.Style" parent= "@android:style/Animation.Translucent" type= "text/css" ><item name=android:windowEnterAnimation> @anim /base_slide_right_in</item> <item name=android:windowExitAnimation> @anim /base_slide_right_out</item></style> 然后让apptheme的 1 android:windowAnimationStyle为上面的style 1 2 3 <style name= "AppTheme" parent= "AppBaseTheme" type= "text/css" ><item name=android:windowAnimationStyle> @style /Animation.Activity.Translucent.Style</item> <item name=android:windowBackground> @android :color/transparent</item> <item name=android:windowIsTranslucent> true </item></style> 假设想在全部的activity切换时候使用该theme,能够配置application,也能够单个单个配置在activity里面。 当然首页退出的时候能够单独配置MainActivity的退出动画和进入动画 1 <style name= "Animation.Activity.Translucent.Style.Main" parent= "@android:style/Animation.Translucent" type= "text/css" ><item name=android:windowExitAnimation> @anim /slide_right_out</item></style> MainActivity的退出和进入动画能够引用系统提供的,可是好像在style里面配置引用不了有些系统的anim, 在目录sdkplatformsandroid-20data es以下。activity_open_enter.xml,activity_close_exit.xml能够直接复制到项目中。改动 单独写一个进入或者退出。然后其他默认。。。 。。。。 多动手,測试,假设有错误的地方麻烦留言一起交流,谢谢 还有一篇值得看的文章:(http://blog.csdn.net/u012970411/article/details/16981441) 前几天Boss就反应说,机器每次启动程序都会闪一下黑屏,这个客户不接受。 没办法,仅仅能想想怎么解决,最后找到了以下的方法。闪黑屏的原因主要是我们启动Activity的时候,须要跑完onCreate和onResume才会显示界面。 也就是说须要处理一些数据后,才会显示。依照这样的思路,是不是我把初始化的工作尽量降低就能够避免黑屏?事实是,就算你onCreate啥都不做。仍然会闪一下黑屏。由于初始化解析界面时须要一定时间。以下是解决的方法: (PS:新建的QQ群,有兴趣能够增加一起讨论:Android群:322599434) 1、自己定义Theme //Edited by mythou //http://www.cnblogs.com/mythou/ //1、设置背景图Theme <style name="Theme.AppStartLoad" parent="android:Theme"> <item name="android:windowBackground">@drawable/ipod_bg</item> <item name="android:windowNoTitle">true</item> </style> //2、设置透明Theme <style name="Theme.AppStartLoadTranslucent" parent="android:Theme"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle">true</item> </style> 上面我定义了两种Theme,第一种Theme就是设置一张背景图。当程序启动时。首先显示这张背景图,避免出现黑屏。另外一种Theme是把样式设置为透明,程序启动后不会黑屏而是整个透明了,等到界面初始化完才一次性显示出来。以下说说两种方式的优缺点: Theme1 程序启动快,界面先显示背景图,然后再刷新其它界面控件。 给人刷新不同步感觉。 Theme2 给人程序启动慢感觉。界面一次性刷出来,刷新同步。 2、改动AndroidManifest.xml 为了使上面Theme生效。我们须要设置一些Activity的Theme //Edited by mythou //http://www.cnblogs.com/mythou/ <application android:allowBackup="true" android:icon="@drawable/ipod_icon" android:label="@string/app_name" android:launchMode="singleTask"> <!-- iPod主界面 --> <activity android:name="com.apical.apicalipod.IPodMainActivity" <!-- 使用上面定义的样式 mythou--> android:theme="@style/Theme.AppStartLoad" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> //...... </application> 能够在Activity里面添加上面自己定义的样式。 另外在Application里面添加也是能够的,并且是全局效果。 自己定义Theme放在 /res/values/styles.xml 里面。假设没有这个文件,自己加入一个就可以。 假设存在多个Activity切换。中间也可能会存在短暂黑屏问题。原因也是Activity启动的时候须要初始化载入数据。假设想避免这样的情况,能够在你切换的Activity里面添加上面的样式。 上面两种样式都能够避免黑屏。 能够实际測试一下你的程序选择一种效果。 这个仅仅是把黑屏避免了,可是假设你程序初始化启动慢。还是会给人程序启动慢的感觉。须要自行优化程序初始化过程。 3、Theme属性具体解释 //Edited by mythou //http://www.cnblogs.com/mythou/ android:theme="@android:style/Theme.Dialog" //Activity显示为对话框模式 android:theme="@android:style/Theme.NoTitleBar" //不显示应用程序标题栏 android:theme="@android:style/Theme.NoTitleBar.Fullscreen" //不显示应用程序标题栏,并全屏 android:theme="Theme.Light " //背景为白色 android:theme="Theme.Light.NoTitleBar" //白色背景并无标题栏 android:theme="Theme.Light.NoTitleBar.Fullscreen" //白色背景,无标题栏,全屏 android:theme="Theme.Black" //背景黑色 android:theme="Theme.Black.NoTitleBar" //黑色背景并无标题栏 android:theme="Theme.Black.NoTitleBar.Fullscreen" //黑色背景,无标题栏。全屏 android:theme="Theme.Wallpaper" //用系统桌面为应用程序背景 android:theme="Theme.Wallpaper.NoTitleBar" //用系统桌面为应用程序背景。且无标题栏 android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" //用系统桌面为应用程序背景。无标题栏,全屏 android:theme="Theme.Translucent" //透明背景 android:theme="Theme.Translucent.NoTitleBar" //透明背景并无标题 android:theme="Theme.Translucent.NoTitleBar.Fullscreen" //透明背景并无标题。全屏 android:theme="Theme.Panel " //面板风格显示 android:theme="Theme.Light.Panel" //平板风格显示 4、Theme和Style Android里面除了Theme外还有Style。比如以下是Launcher里面配置workspace的一个Style //Edited by mythou //http://www.cnblogs.com/mythou/ <style name="WorkspaceIcon"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">match_parent</item> <item name="android:layout_gravity">center</item> <item name="android:gravity">center_horizontal</item> <item name="android:singleLine">true</item> <item name="android:ellipsize">marquee</item> <item name="android:textSize">12sp</item> <item name="android:textColor">#FFF</item> <item name="android:shadowRadius">2.0</item> <item name="android:shadowColor">#B0000000</item> </style> Style能够理解为一组属性集合。方便不同的View设置使用。我们在View里面使用Style的时候,跟使用Theme是一样的应用方法。那么Style和Theme有什么差别?以下列出两者差别: 样式用在单独的View。如:Button、TextView等 主题通过AndroidManifest.xml中的<application>和<activity>用在整个应用或者某个 Activity,主题对整个应用或某个Activity存在全局性影响。 假设一个应用使用了主题,同一时候应用下的view也使用了样式,那么当主题与样式属性发生冲突时,样式的优先级高于主题。 上面就是通过Theme解决程序启动闪黑屏问题,而且解说了Theme和Style,通过Theme配置,事实上还能够做个欢迎页面。只是我们都希望程序启动速度越快越好。因此还是须要多多优化自己的程序。 本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5417379.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android UI开发第六篇——仿QQ的滑动Tab

代码下载地址:http://www.devdiv.com/thread-101454-1-1.html 使用了ActivityGroup。 publicclassMainActivityextendsActivityGroup{ privateRelativeLayoutlayout; privateRelativeLayoutlayout1; privateRelativeLayoutlayout2; privateRelativeLayoutlayout3; privateRelativeLayoutbodylayout; privateImageViewtab1; privateImageViewtab2; privateImageViewtab3; privateImageViewfirst; privateintcurrent=1;//默认选中第一个,可以动态的改变此参数值 publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); initUI(); } privatevoidinitUI(){ layout=(RelativeLayout)findViewById(R.id.root); layout1=(RelativeLayout)findViewById(R.id.layout1); layout2=(RelativeLayout)findViewById(R.id.layout2); layout3=(RelativeLayout)findViewById(R.id.layout3); bodylayout=(RelativeLayout)findViewById(R.id.bodylayout); tab1=(ImageView)findViewById(R.id.tab1); tab1.setOnClickListener(onClickListener); tab2=(ImageView)findViewById(R.id.tab2); tab2.setOnClickListener(onClickListener); tab3=(ImageView)findViewById(R.id.tab3); tab3.setOnClickListener(onClickListener); RelativeLayout.LayoutParamsrl=newRelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); rl.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE); first=newImageView(this); first.setTag("first"); first.setImageResource(R.drawable.topbar_select); //默认选中项 switch(current){ case1: layout1.addView(first,rl); current=R.id.tab1; break; case2: layout2.addView(first,rl); current=R.id.tab2; break; case3: layout3.addView(first,rl); current=R.id.tab3; break; default: break; } Viewview=getLocalActivityManager().startActivity("index", newIntent(MainActivity.this,Tab1.class)) .getDecorView(); bodylayout.addView(view); } privatebooleanisAdd=false;//是否添加过top_select privateintselect_width;//top_select_width privateintselect_height;//top_select_height privateintfirstLeft;//第一次添加后的左边距***** privateintstartLeft;//起始左边距 //添加一个view,移除一个view privatevoidreplace(){ switch(current){ caseR.id.tab1: changeTop(layout1); break; caseR.id.tab2: changeTop(layout2); break; caseR.id.tab3: changeTop(layout3); break; default: break; } } privatevoidchangeTop(RelativeLayoutrelativeLayout){ ImageViewold=(ImageView)relativeLayout.findViewWithTag("first");; select_width=old.getWidth(); select_height=old.getHeight(); RelativeLayout.LayoutParamsrl=newRelativeLayout.LayoutParams(select_width,select_height); rl.leftMargin=old.getLeft()+((RelativeLayout)old.getParent()).getLeft(); rl.topMargin=old.getTop()+((RelativeLayout)old.getParent()).getTop(); //获取起始位置 firstLeft=old.getLeft()+((RelativeLayout)old.getParent()).getLeft(); ImageViewiv=newImageView(this); iv.setTag("move"); iv.setImageResource(R.drawable.topbar_select); layout.addView(iv,rl); relativeLayout.removeView(old); } privateOnClickListeneronClickListener=newOnClickListener(){ publicvoidonClick(Viewv){ if(!isAdd){ replace();//初次使用移除old添加新的top_select为RelativeLayout所使用 isAdd=true; } ImageViewtop_select=(ImageView)layout.findViewWithTag("move"); inttabLeft; intendLeft=0; booleanrun=false; switch(v.getId()){ caseR.id.tab1: if(current!=R.id.tab1){ //中心位置 tabLeft=((RelativeLayout)tab1.getParent()).getLeft()+tab1.getLeft()+tab1.getWidth()/2; //最终位置 endLeft=tabLeft-select_width/2; current=R.id.tab1; run=true; bodylayout.removeAllViews(); Viewview=getLocalActivityManager().startActivity("index", newIntent(MainActivity.this,Tab1.class)) .getDecorView(); bodylayout.addView(view); } break; caseR.id.tab2: if(current!=R.id.tab2){ tabLeft=((RelativeLayout)tab2.getParent()).getLeft()+tab2.getLeft()+tab2.getWidth()/2; endLeft=tabLeft-select_width/2; current=R.id.tab2; run=true; bodylayout.removeAllViews(); Viewview=getLocalActivityManager().startActivity("index", newIntent(MainActivity.this,Tab2.class)) .getDecorView(); bodylayout.addView(view); } break; caseR.id.tab3: if(current!=R.id.tab3){ tabLeft=((RelativeLayout)tab3.getParent()).getLeft()+tab3.getLeft()+tab3.getWidth()/2; endLeft=tabLeft-select_width/2; current=R.id.tab3; run=true; bodylayout.removeAllViews(); Viewview=getLocalActivityManager().startActivity("index", newIntent(MainActivity.this,Tab3.class)) .getDecorView(); bodylayout.addView(view); } break; default: break; } if(run){ TranslateAnimationanimation=newTranslateAnimation(startLeft,endLeft-firstLeft,0,0); startLeft=endLeft-firstLeft;//重新设定起始位置 animation.setDuration(400); animation.setFillAfter(true); top_select.bringToFront(); top_select.startAnimation(animation); } } }; } <?xmlversion="1.0"encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/root" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/default_bg" > <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="6.0" > <RelativeLayout android:id="@+id/layout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0" android:layout_gravity="center_vertical" > <ImageView android:id="@+id/tab1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/tab1" android:layout_centerInParent="true" /> </RelativeLayout> <RelativeLayout android:id="@+id/layout2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0" android:layout_gravity="center_vertical" > <ImageView android:id="@+id/tab2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/tab2" android:layout_centerInParent="true" /> </RelativeLayout> <RelativeLayout android:id="@+id/layout3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0" android:layout_gravity="center_vertical" > <ImageView android:id="@+id/tab3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/tab3" android:layout_centerInParent="true" /> </RelativeLayout> </LinearLayout> <RelativeLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" android:background="#ffffff" android:gravity="center" android:id="@+id/bodylayout" > </RelativeLayout> </LinearLayout> </RelativeLayout> 本文转自xyz_lmn51CTO博客,原文链接:http://blog.51cto.com/xyzlmn/817371 ,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android UI开发第十一篇——右上角带个泡泡

一个网友问到“一个新消息Button按钮,上边浮着一个泡泡形状提示有几条新消息!”是怎么实现的,我这简单写了一下,其实就是view的组合。 <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/white" > <RelativeLayout android:id="@+id/gridview_item_layout" android:layout_width="190dip" android:layout_height="190dip" android:background="@drawable/usb_android" > <TextViewandroid:id="@+id/textView1" android:layout_alignParentRight="true" android:text="3" android:textColor="@android:color/white" android:background="@drawable/btn_circle_selected" android:gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> </RelativeLayout> </LinearLayout> publicclassPaopaoActivityextendsActivity{ @Override protectedvoidonCreate(BundlesavedInstanceState){ //TODOAuto-generatedmethodstub super.onCreate(savedInstanceState); setContentView(R.layout.main2); } } http://www.devdiv.com/home.php?mod=space&uid=14682&do=blog&id=4118 本文转自xyz_lmn51CTO博客,原文链接:http://blog.51cto.com/xyzlmn/817325,如需转载请自行联系原作者

优秀的个人博客,低调大师

推荐12个Android开发源码(包括应用、游戏、效果等等)

适用环境:Android 2.1 分享给给位初学者,当中有不错的效果值得学习收藏的哦~ 先上传12个经典源码~后续测试内容敬请期待~~~ 1.冒险类游戏:终极大逃亡 http://www.apkbus.com/android-88896-1-1.html 2. 奇艺高清UI界面源码 http://www.apkbus.com/android-88507-1-1.html 3. 是男人就下100层英文原版 http://www.apkbus.com/android-88877-1-1.html 4. 界面还不错的足球游戏分享 http://www.apkbus.com/android-88851-1-1.html 5. 动画顺序播放源码 http://www.apkbus.com/android-88515-1-1.html 6. 无损捕鱼达人源码 http://www.apkbus.com/android-88511-1-1.html 7. 策略型大型战争游戏 http://www.apkbus.com/android-88881-1-1.html 8. 斗地主源码分享 http://www.apkbus.com/android-88862-1-1.html 9. 再放精品推箱子游戏 http://www.apkbus.com/android-88523-1-1.html 10. 简易音乐播放器源码 http://www.apkbus.com/android-88512-1-1.html 11. ViewPager+Fragment实现QQ界面 http://www.apkbus.com/android-88510-1-1.html 12. 图片浏览源码 http://www.apkbus.com/android-88503-1-1.html 更多资源尽在:http://www.apkbus.com/Android-44-1.html 本文转自qianqianlianmeng博客园博客,原文链接:http://www.cnblogs.com/aimeng/archive/2012/12/27/2836205.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android GIS开发系列-- 入门季(10) MapView快速定位到Geometry

我们知道某个Geometry的坐标,但不知道具体的位置,该如何使地图快速定位呢?这时需要用到MapView.setExtent方法,来看下这个方法的介绍:Zooms the map to the given geometry so that geometry fits within the bounds of the map.大体的意思即缩小地图定位到Geometry。上代码: public class MainActivity extends Activity { private MapView mapView; private GraphicsLayer graphicsLayer; private static final String TILED_WORLD_STREETS_URL = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mapView = (MapView) findViewById(R.id.map_view); mapView.addLayer(new ArcGISTiledMapServiceLayer(TILED_WORLD_STREETS_URL)); findViewById(R.id.location).setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { //快速定位到线 Polyline polyline = new Polyline(); polyline.startPath(new Point(110, 23)); polyline.lineTo(new Point(115, 25)); //由于加载的地图是墨卡托坐标,这里需要转坐标 Polyline polyline2 = (Polyline) GeometryEngine.project(polyline, SpatialReference.create(SpatialReference.WKID_WGS84), SpatialReference .create(SpatialReference.WKID_WGS84_WEB_MERCATOR)); mapView.setExtent(polyline2); } }); initLayer(); } /** * 添加一条线 */ private void initLayer() { graphicsLayer = new GraphicsLayer(); mapView.addLayer(graphicsLayer); Polyline polyline = new Polyline(); polyline.startPath(new Point(110, 23)); polyline.lineTo(new Point(115, 25)); //由于加载的地图是墨卡托坐标,这里需要转坐标 Polyline polyline2 = (Polyline) GeometryEngine.project(polyline, SpatialReference.create(SpatialReference.WKID_WGS84), SpatialReference .create(SpatialReference.WKID_WGS84_WEB_MERCATOR)); graphicsLayer.addGraphic(new Graphic(polyline2, new SimpleLineSymbol( Color.RED, 3, SimpleLineSymbol.STYLE.SOLID))); } } 没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。 本文转自wenglabs博客园博客,原文链接:http://www.cnblogs.com/arxive/p/7751971.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册