当前位置: 首页 > news >正文

设计师网站兼职系统下载 网站 源码

设计师网站兼职,系统下载 网站 源码,金隅嘉华大厦网站建设公司,陕西网站建设企业Android 系统桌面 App —— Launcher 开发#xff08;1#xff09; Launcher简介 Launcher就是Android系统的桌面#xff0c;俗称“HomeScreen”也就是我们开机后看到的第一个App。launcher其实就是一个app#xff0c;它的作用是显示和管理手机上其他App。目前市场上有很…Android 系统桌面 App —— Launcher 开发1 Launcher简介 Launcher就是Android系统的桌面俗称“HomeScreen”也就是我们开机后看到的第一个App。launcher其实就是一个app它的作用是显示和管理手机上其他App。目前市场上有很多第三方的launcher应用比如“小米桌面”、“91桌面”等等 注册AndroidManifest 要让app作为Launcher需要在Manifest中添加两个category category android:nameandroid.intent.category.HOME/ category android:nameandroid.intent.category.DEFAULT/ 添加后的代码 activity android:name.MainActivityintent-filteraction android:nameandroid.intent.action.MAIN/category android:nameandroid.intent.category.HOME/category android:nameandroid.intent.category.DEFAULT/category android:nameandroid.intent.category.LAUNCHER//intent-filter /activity 此时安装此app之后点击Home键就会看到以下界面让你选择使用哪一个桌面应用 如果选择我们自己开发的 Launcher App就会启动 我们自己的桌面应用目前这个应用是空白的需要添加应用列表以及相应的点击事件。 注意普通的安卓手机都能看到另外一个界面但是像小米、华为这样的手机就不行。 使用PackageManager扫描所有app 编辑MainActivity public class MainActivity extends AppCompatActivity { ​Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);   //获取所有app设置adapterPackageManager pm getPackageManager();Intent mainIntent new Intent(Intent.ACTION_MAIN, null);mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);final ListResolveInfo activities pm.queryIntentActivities(mainIntent, 0);RecyclerView recyclerView findViewById(R.id.rv);AppAdapter adapter new AppAdapter(activities, this);recyclerView.setAdapter(adapter);recyclerView.setLayoutManager(new GridLayoutManager(this, 3));} } 我们在MainActivity中使用PackageManager的queryIntentActivities方法扫描出手机上已安装的所有app信息。 activity_main 布局代码 ?xml version1.0 encodingutf-8? androidx.constraintlayout.widget.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:context.MainActivity ​androidx.recyclerview.widget.RecyclerViewandroid:idid/rvAppsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent / /androidx.constraintlayout.widget.ConstraintLayout 由于布局中使用了 RecyclerView记得导入 RecyclerView 库 implementation androidx.recyclerview:recyclerview:1.1.0 显示app信息添加点击事件 新建AppAdapter类 public class AppAdapter extends RecyclerView.AdapterAppAdapter.ViewHolder { ​private ListResolveInfo mList;private Context mContext; ​public AppAdapter(ListResolveInfo list, Context context) {this.mList list;this.mContext context;} ​NonNullOverridepublic AppAdapter.ViewHolder onCreateViewHolder(NonNull ViewGroup parent, int viewType) {View inflate LayoutInflater.from(mContext).inflate(R.layout.rv_item, parent, false);//作为一个view填充View view View.inflate(parent.getContext(), R.layout.rv_item, null);return new ViewHolder(view);} ​Overridepublic void onBindViewHolder(NonNull final AppAdapter.ViewHolder holder, final int position) {holder.mIcon.setImageDrawable(mList.get(position).loadIcon(mContext.getPackageManager()));holder.mTtile.setText(mList.get(position).loadLabel(mContext.getPackageManager()));holder.itemView.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {Intent launchIntent new Intent();launchIntent.setComponent(new ComponentName(mList.get(position).activityInfo.packageName,mList.get(position).activityInfo.name));mContext.startActivity(launchIntent);}});} ​Overridepublic int getItemCount() {return mList null ? 0 : mList.size();} ​public class ViewHolder extends RecyclerView.ViewHolder {private ImageView mIcon;private TextView mTtile; ​public ViewHolder(NonNull View itemView) {super(itemView);mIcon itemView.findViewById(R.id.iv);mTtile itemView.findViewById(R.id.tv);}} } 在此类中使用activityInfo.loadIcon方法加载app图标使用resolveInfo.loadLabel方法加载app名字并且添加了点击启动对应app的点击事件。 rv_item布局文件如下 ?xml version1.0 encodingutf-8? androidx.constraintlayout.widget.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:padding10dp ​ImageViewandroid:idid/ivIconandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:maxWidth36dpandroid:maxHeight36dpapp:layout_constraintBottom_toTopOfid/tvNameapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparenttools:srcmipmap/ic_launcher / ​TextViewandroid:idid/tvNameandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:ellipsizeendandroid:lines1android:singleLinetrueapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toBottomOfid/ivIcontools:textstring/app_name / ​ /androidx.constraintlayout.widget.ConstraintLayout 运行效果 设置桌面背景 首先第一步我们需要先让背景显示出来在res/valuses/styles.xml文件下添加如下代码 style nameLauncherAppTheme parentandroid:Theme.Wallpaper.NoTitleBar!-- Customize your theme here. --item namecolorPrimarycolor/colorPrimary/itemitem namecolorPrimaryDarkcolor/colorPrimaryDark/itemitem namecolorAccentcolor/colorAccent/itemitem namewindowNoTitletrue/item /style 接着在AndroidManifest.xml中使用这个Theme applicationandroid:allowBackuptrueandroid:iconmipmap/ic_launcherandroid:labelstring/app_nameandroid:roundIconmipmap/ic_launcher_roundandroid:supportsRtltrueandroid:themestyle/LauncherAppTheme... 因为是app关系需要适配状态栏。添加transparentStatusBarForImage方法在onCreate()的setContentView(R.layout.activity_main);后调用 public void transparentStatusBarForImage(Activity context) {if (Build.VERSION.SDK_INT Build.VERSION_CODES.LOLLIPOP) {//5.0 全透明实现//getWindow.setStatusBarColor(Color.TRANSPARENT)Window window context.getWindow();window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);window.setStatusBarColor(Color.TRANSPARENT);} else if (Build.VERSION.SDK_INT Build.VERSION_CODES.KITKAT) {//4.4 全透明状态栏context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);}} 使用 Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);transparentStatusBarForImage(this);} 会出现图标也上去的问题在主界面的xml文件中增加android:fitsSystemWindowstrue即可 app图标大小不一样的问题可以通过写死尺寸来控制 ?xml version1.0 encodingutf-8? androidx.constraintlayout.widget.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:padding10dp​ImageViewandroid:idid/ivandroid:layout_width48dpandroid:layout_height48dpandroid:scaleTypefitXYapp:layout_constraintBottom_toTopOfid/tvapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparenttools:srcmipmap/ic_launcher / ​TextViewandroid:idid/tvandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:ellipsizeendandroid:lines1android:singleLinetrueapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toBottomOfid/ivtools:textstring/app_name / ​ /androidx.constraintlayout.widget.ConstraintLayout 其他问题 1.打开应用后会把华为桌面应用给关掉怎么做到的不是关掉是把回退屏蔽了不允许退出。home键还是好用的回到原主界面 2.锁屏后放置一段时间它还在还存活存活 3.定制度比较低的安卓系统怎么找到对应的系统级别签名去找Android各个版本的源码哪里有签名文件 第一个问题 Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {if ((keyCode KeyEvent.KEYCODE_BACK)) { //           Toast.makeText(this, 按下了back键   onKeyDown(), Toast.LENGTH_SHORT).show();return false;}else {return super.onKeyDown(keyCode, event);}} 第二个问题 界面还会在没有回收。 注这篇文章只是简单的桌面app实现 参考 Android 系统桌面 App —— Launcher 开发 recycleview的方式 android手把手教你开发launcher一AndroidStudio版 Launcher开发——入门篇 还有后续 Android安卓-开发一个android桌面 GridView的方式 Launcher3 包含Launcher3开发的源码解析
http://www.zqtcl.cn/news/98022/

相关文章:

  • 个人网站设计毕业设计论文上海百度seo优化
  • 展台设计网站都有哪些拓者设计吧手机版
  • 河南省级建设主管部门网站免费推广平台哪个好
  • wordpress禁止自动升级seo实战密码怎么样
  • 福永网站建设公司如何利用个人nas做网站
  • 北京网站seo外包wordpress心情
  • 租用服务器一般是谁帮助维护网站安全网站如何看是哪家公司做的
  • 戴尔网站建设的特点开创者wordpress素材
  • 网站假设公司排名不用囤货
  • 有关网站建设合同织梦珠宝网站模板
  • 月牙河做网站公司电商网站开发成本
  • iis7建立网站注册公司地址虚拟地址怎么申请
  • 响应式网站开发的想要去国外网站买东西怎么做
  • 网站建设开发有什么好处百度网盘0基础网站开发教程
  • 桂林整站优化青岛网站制作哪里有
  • 织梦cms手机网站源码天天想你视频免费观看西瓜
  • 怎么做网站弄网盟邯郸超速云_网站建设
  • 桂阳做网站的软件定制开发外包wordpress电子商务插件
  • 10有免费建网站那些公司做网站比较厉害
  • 网站关键词优化推广旅游类网站开发开题报告范文
  • 官方网站营销拟在建项目信息网官网
  • 沈阳做微信和网站的公司湛江网站建设公司哪家好
  • 网站 开发逻辑电话销售电销系统
  • 有哪些做兼职的设计网站有哪些工作可以用asp做哪些网站
  • 装修网站推广方案东莞网站建设0086
  • 知名营销网站开发高端网站建设如何收费
  • 佛山网站建设邓先生沈阳做网站找黑酷科技
  • 网站建设 排名下拉请教个人主页网站怎么做啊
  • 揭阳网站制作教程安阳seo公司
  • 网站运营管理教材wordpress 评论框插件