当前位置: 移动技术网 > IT编程>移动开发>Android > Android开发实现Launcher3应用列表修改透明背景的方法

Android开发实现Launcher3应用列表修改透明背景的方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

忘词帝文摘,东阳教育网首页,热血教师

本文实例讲述了android开发实现launcher3应用列表修改透明背景的方法。分享给大家供大家参考,具体如下:

launcher时开机完成后第一个启动的应用,用来展示应用列表和快捷方式、小部件等。launcher作为第一个(开机后第一个启动的应用)展示给用户的应用程序,其设计的好坏影响到用户的体验,甚至影响用户购机的判断。所以很多品牌厂商都会不遗余力的对launcher进行深度定制,如小米的miui、华为的emui等。android默认的launcher没有过多的定制,更加简洁,受到源生党的追捧,google的nexus系列手机基本都是用的源生launcher,目前android源生的launcher版本是launcher3。

前面总结了一些常见的,这里来分析一下launcher3的应用列表背景的修改技巧。

将launcher3的应用列表背景修改为透明,与launcher2略有不同,需要进行如下步骤:

1. 找到res/layout/apps_customize_pane.xml文件,将

<com.android.launcher3.appscustomizetabhost
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:background="#ff000000">

修改为:

<com.android.launcher3.appscustomizetabhost
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:background="#00000000">

将动画部分

<framelayout
android:id="@+id/animation_buffer" 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff000000"
android:visibility="gone" />

修改为:

<framelayout
 android:id="@+id/animation_buffer" 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:visibility="gone" />

2、找到appscustomizetabhost.java类中的ontabchangedend()方法,如下:

private void ontabchangedend(appscustomizepagedview.contenttype type) {
    int bgalpha = (int) (255 * (getresources().getinteger(
      r.integer.config_appscustomizespringloadedbgalpha) / 100f));
    setbackgroundcolor(color.argb(bgalpha, 0, 0, 0));
    mappscustomizepane.setcontenttype(type);
}

其中bgalpha为透明度的参数,将其改为你需要的透明度即可,255为不透明,以上1、2步骤完之后,保存,编译,即可达到需要的效果。

更多关于android相关内容感兴趣的读者可查看本站专题:《android开发入门与进阶教程》、《android调试技巧与常见问题解决方法汇总》、《android多媒体操作技巧汇总(音频,视频,录音等)》、《android基本组件用法总结》、《android视图view技巧总结》、《android布局layout技巧总结》及《android控件用法总结

希望本文所述对大家android程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网