android4.4 launcher2實現應用列表背景透明

來源:互聯網
上載者:User

由於做android系統開發,在研發的車機上希望將launcher2的應用列表背景由黑色修改為透明,修改如下:

1. 找到res/layout/apps_customize_pane.xml檔案,將

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:background="#FF000000">

修改為:

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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF000000"
android:visibility="gone" />

修改為:

<frameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:visibility="gone" />

2. 開啟com/android/launcher2/Launcher.java代碼,將其中的對updateWallpaperVisibility函數的調用參數都修改為true。

3. 開啟com/android/launcher2/AppsCustomizeTabHost.java代碼,在onFinishInflate()方法中設定透明度:

mContent.setBackgroundColor(Color.argb(100, 0, 0, 0))。

4. 編譯運行,即可看到應用列表背景變為透明。

diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index d0be08c..6326401 100755
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2457,7 +2457,7 @@ public final class Launcher extends Activity
if (isAllAppsVisible()) {
if (mAppsCustomizeTabHost != null &&
!mAppsCustomizeTabHost.isTransitioning()) {
- updateWallpaperVisibility(false);
+ updateWallpaperVisibility(true);
}
}
}
@@ -2630,7 +2630,7 @@ public final class Launcher extends Activity
hideDockDivider();
}
if (!animationCancelled) {
- updateWallpaperVisibility(false);
+ updateWallpaperVisibility(true);
}

// Hide the search bar
@@ -2710,7 +2710,7 @@ public final class Launcher extends Activity
dispatchOnLauncherTransitionPrepare(toView, animated, false);
dispatchOnLauncherTransitionStart(toView, animated, false);
dispatchOnLauncherTransitionEnd(toView, animated, false);
- updateWallpaperVisibility(false);
+ updateWallpaperVisibility(true);
}
}


diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
old mode 100644
new mode 100755
index 225b056..c76b428
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -22,6 +22,7 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -106,6 +107,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mContent = (LinearLayout) findViewById(R.id.apps_customize_content);
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();

+ mContent.setBackgroundColor(Color.argb(100, 0, 0, 0));
+
// Configure the tabs content factory to return the same paged view (that we change the
// content filter on)
TabContentFactory contentFactory = new TabContentFactory() {

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.