android4.2 Launcher2界面两边的渐变的去除方法

android4.2 Launcher2界面两边的渐变的去除方法
1

作者:ka布更新于 05月06日访问(1383评论(6

android4.2 Launcher2主界面效果如下图:
6597954873518222086.jpg
如图所示,左右两边有黑色的渐变,看起来感觉怪怪的。现提供一种去掉它的方法。

步骤1
打开文件launcher.xml,将下述代码片段中的android:background属性去掉。
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
android:id="@+id/launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/workspace_bg">

<com.android.launcher2.DragLayer
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"

    android:id="@+id/drag_layer"
    android:background="@drawable/workspace_bg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

调整后的情况如下:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
android:id="@+id/launcher"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.android.launcher2.DragLayer
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"

    android:id="@+id/drag_layer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

步骤2
打开文件Launcher2.java,不难看出,代码中有
private Drawable mWorkspaceBackgroundDrawable;
private Drawable mBlackBackgroundDrawable;
两个属性,用于绘制wordkspace背景。继续往下跟踪代码,可找到下面的代码片段
mWorkspaceBackgroundDrawable = getResources().getDrawable(R.drawable.workspace_bg);
mBlackBackgroundDrawable = new ColorDrawable(Color.BLACK);
......
......
private void setWorkspaceBackground(boolean workspace) {
mLauncherView.setBackground(workspace ?
mWorkspaceBackgroundDrawable : mBlackBackgroundDrawable);
}
方法setWorkspaceBackground大意是根据布尔量wordspace的值情况选用不同的属性绘制背景,这里,我们选择将此方法的内容注释掉。变成
private void setWorkspaceBackground(boolean workspace) {
//mLauncherView.setBackground(workspace ?
// mWorkspaceBackgroundDrawable : mBlackBackgroundDrawable);
}

步骤3
重新构建Launcher2.apk,push进机器验证,得到下图所示效果。完成此需求,方法有多种,大家可以深入了解代码实现,取最佳最优的处理方法。
6597688791704290564 _1_.jpg


my 163 blog addr is http://kinglaw05.blog.163.com/

声明:eoe文章著作权属于作者,受法律保护,转载时请务必以超链接形式附带如下信息

原文作者: ka布

原文地址: http://my.eoe.cn/kinglaw/archive/3355.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值