本文實例講述了Android開發實現Launcher3應用列表修改透明背景的方法。分享給大家供大家參考,具體如下:
Launcher時開機完成后第一個啟動的應用,用來展示應用列表和快捷方式、小部件等。Launcher作為第一個(開機后第一個啟動的應用)展示給用戶的應用程序,其設計的好壞影響到用戶的體驗,甚至影響用戶購機的判斷。所以很多品牌廠商都會不遺余力的對Launcher進行深度定制,如小米的MIUI、華為的EMUI等。Android默認的Launcher沒有過多的定制,更加簡潔,受到源生黨的追捧,Google的Nexus系列手機基本都是用的源生Launcher,目前Android源生的Launcher版本是Launcher3。
前面總結了一些常見的launcher3配置修改方法,這里來分析一下launcher3的應用列表背景的修改技巧。
將launcher3的應用列表背景修改為透明,與Launcher2略有不同,需要進行如下步驟:
1. 找到res/layout/apps_customize_pane.xml文件,將
<com.android.launcher3.appscustomizetabhostxmlns: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.appscustomizetabhostxmlns:android="http://schemas.android.com/apk/res/android"xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"android:background="#00000000">
將動畫部分
<frameLayoutandroid: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程序設計有所幫助。
新聞熱點
疑難解答