由于做android系统开发,在研发的车机上希望将launcher2的应用列表背景由黑色修改为透明,修改如下:

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

<com.android.launcher2.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.launcher2.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.打开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() {

更多相关文章

  1. Android自定义ActionBar背景色、字体颜色等样式style
  2. 解决android logcat不打印信息
  3. Android(安卓)Studio很卡,操作很不顺的点进来!
  4. android自定义dialog弹出框、透明背景
  5. Android(安卓)Studio 3.x.x降低compileSdkVersion的SDK版本
  6. android开关机动画和铃声配置
  7. Android打开其它APP的两种方式
  8. (转)Unable to get view server version from device emulator-5
  9. Android(安卓)7.0修改系统时间

随机推荐

  1. Android studio Gradle home can not be
  2. Android图形显示系统——概述
  3. Android API demos 阅读笔记
  4. 系统总结归纳一下android
  5. Android的Intent Filter详解
  6. 作为一个IOS\android开发者,转行到RN的
  7. Android(安卓)Input Framework(二)---Eve
  8. Android 开发者从0到1发布一个微信小程序
  9. Android的跨进程通信介绍---------------
  10. Android 7 强势来袭开发者们不得不知道的