首页 文章 精选 留言 我的

精选列表

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

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 ,如需转载请自行联系原作者

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

推荐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 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,如需转载请自行联系原作者

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

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,如需转载请自行联系原作者

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

【iOS 开发】UIApplicationDelegate 中两个值得注意的地方

01 - app 的第一个执行代码的机会是什么 新建工程的时候,Xcode 默认创建的 AppDelegate 文件里面会有 UIApplicationDelegate 的 6 个代理方法,其中第一个是 application:didFinishLaunchingWithOptions:,我们通常会在这里进行 SDK 的初始化以及其他一些配置等等,但是 app 的第一个执行代码的机会其实是 application:willFinishLaunchingWithOptions:,官方注解是: This method is your app’s first chance to execute code at launch time. 这个知识点可以用于面试,以及对于一些对初始化时机有要求的 SDK 配置的 bug 排查。 02 - 应该在哪个回调里面存储数据 applicationDidEnterBackground 官方已经写清注释,应该在 applicationDidEnterBackground: 来进行数据的保护性存储,但是考虑一种特殊情况: 直接连按 home 键,然后上划杀死 app,这个方法还会调用吗? State changes in an iOS app 答案是会的,应用从 active 状态至 suspended 状态,是必须经过 background 状态的,我们应该按照官方规范,在 applicationDidEnterBackground: 方法而不是在可能被调用更多次的 applicationWillResignActive: 方法里面进行数据的保护性存储。 参考链接:https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

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文件系统,支持十年生命周期更新。

用户登录
用户注册