首页 文章 精选 留言 我的

精选列表

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

自定义菜单,仿优酷菜单

效果图如下:点击主页后,上面2个圆环旋转消失与出现,点击中间圆环的中间那个菜单按钮,最外围的圆环旋转消失于出现 利用了自定义控件技术,以及图片的旋转和布局时各个控件的相对关系。 1、acitivity_main.xml的布局文件 <?xmlversion="1.0"encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.yuanlp.youkudemo.MainActivity"> <RelativeLayout android:id="@+id/level3" android:layout_width="280dp" android:layout_height="140dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@drawable/level3"> <ImageView android:id="@+id/channel1" android:layout_marginLeft="8dp" android:layout_marginBottom="8dp" android:layout_alignParentBottom="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/channel1"/> <ImageView android:id="@+id/channel2" android:layout_above="@+id/channel1" android:layout_marginLeft="34dp" android:layout_marginBottom="8dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/channel2"/> <ImageView android:id="@+id/channel3" android:layout_above="@+id/channel2" android:layout_marginLeft="66dp" android:layout_marginBottom="8dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/channel3"/> <ImageView android:id="@+id/channel4" android:layout_marginTop="8dp" android:layout_centerHorizontal="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/channel4"/> <ImageView android:id="@+id/channel5" android:layout_above="@+id/channel6" android:layout_marginRight="67dp" android:layout_marginBottom="8dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:src="@drawable/channel5"/> <ImageView android:id="@+id/channel6" android:layout_above="@+id/channel7" android:layout_marginRight="27dp" android:layout_marginBottom="8dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:src="@drawable/channel6"/> <ImageView android:id="@+id/channel7" android:layout_marginRight="9dp" android:layout_marginBottom="8dp" android:layout_alignParentBottom="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:src="@drawable/channel7"/> </RelativeLayout> <RelativeLayout android:id="@+id/level2" android:layout_width="180dp" android:layout_height="90dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@drawable/level2"> <ImageView android:layout_marginLeft="8dp" android:layout_marginBottom="8dp" android:layout_alignParentBottom="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon_search"/> <ImageView android:id="@+id/icon_menu" android:layout_centerHorizontal="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:src="@drawable/icon_menu"/> <ImageView android:layout_marginLeft="8dp" android:layout_marginBottom="8dp" android:layout_alignParentBottom="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:src="@drawable/icon_myyouku"/> </RelativeLayout> <RelativeLayout android:id="@+id/level1" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" android:layout_width="100dp" android:layout_height="50dp" android:background="@drawable/level1"> <ImageView android:id="@+id/icon_home" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/icon_home"/> </RelativeLayout> </RelativeLayout> 2、Tools.java 工具类,具体实现了消失与出现的方法,利用了图片的旋转消失 packagecom.yuanlp.youkudemo; importandroid.view.View; importandroid.view.animation.RotateAnimation; /** *Createdby原立鹏on2017/7/3. *控制level的指定的看控件 */ classTools{ publicstaticvoidhideView(Viewview){ //参数解释:第一个蚕食是从多少开始,第二个是旋转多少度,第三个以及第四个是相对于控件来说,旋转中心的位置,即控件宽度的一半以及高度 RotateAnimationra=newRotateAnimation(0,180,view.getWidth()/2,view.getHeight()); ra.setDuration(500);//设置动画的时间,不然的话直接就没了,没有视觉效果 ra.setFillAfter(true);//动画停留在完成的状态 view.startAnimation(ra);//启动动画 } publicstaticvoidshowView(Viewview){ //参数解释:第一个蚕食是从多少开始,第二个是旋转多少度,第三个以及第四个是相对于控件来说,旋转中心的位置,即控件宽度的一半以及高度 RotateAnimationra=newRotateAnimation(180,360,view.getWidth()/2,view.getHeight()); ra.setDuration(500);//设置动画的时间,不然的话直接就没了,没有视觉效果 ra.setFillAfter(true);//动画停留在完成的状态 view.startAnimation(ra);//启动动画 } } 3、MainActivity.java packagecom.yuanlp.youkudemo; importandroid.os.Bundle; importandroid.support.v7.app.AppCompatActivity; importandroid.view.View; importandroid.widget.ImageView; importandroid.widget.RelativeLayout; publicclassMainActivityextendsAppCompatActivity{ privateImageViewicon_home; privateImageViewicon_menu; privateRelativeLayoutlevel1; privateRelativeLayoutlevel2; privateRelativeLayoutlevel3; //定义一个状态,来控制level3是否显示 privatebooleanisShowLevel3=true; //定义一个状态,来控制level2是否显示 privatebooleanisShowLevel2=true; //定义一个状态,来控制level1是否显示 privatebooleanisShowLevel1=true; @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); level1=(RelativeLayout)findViewById(R.id.level1); level2=(RelativeLayout)findViewById(R.id.level2); level3=(RelativeLayout)findViewById(R.id.level3); icon_home=(ImageView)findViewById(R.id.icon_home); icon_menu=(ImageView)findViewById(R.id.icon_menu); MyOnClickListenermyOnClickListener=newMyOnClickListener(); icon_home.setOnClickListener(myOnClickListener); icon_menu.setOnClickListener(myOnClickListener); } classMyOnClickListenerimplementsView.OnClickListener{ @Override publicvoidonClick(Viewv){ switch(v.getId()){ caseR.id.icon_home: //如果三级菜单和二级菜单都是现实的,那么把2个都设置隐藏 if(isShowLevel2){ isShowLevel2=false; Tools.hideView(level2); if(isShowLevel3){ isShowLevel3=false; Tools.hideView(level3); } }else{ isShowLevel2=true; Tools.showView(level2); } //如果三级菜单和二级菜单都是隐藏的,就显示二级菜单 break; caseR.id.icon_menu: if(isShowLevel3){ //隐藏 isShowLevel3=false; Tools.hideView(level3); }else{ isShowLevel3=true; Tools.showView(level3); } break; } } } }

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

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

Nacos

Nacos

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

Rocky Linux

Rocky Linux

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

用户登录
用户注册
修改密码
忘记密码