1、关闭lancher中搜素栏:
路径:android/packages/apps/Launcher3/src/com/android/launcher3/config/BaseFlags.java
abstract class BaseFlags {
...
// When enabled the promise icon is visible in all apps while installation an app.
public static final boolean LAUNCHER3_PROMISE_APPS_IN_ALL_APPS = false;
// Enable moving the QSB on the 0th screen of the workspace
- public static final boolean QSB_ON_FIRST_SCREEN = true;
+ public static final boolean QSB_ON_FIRST_SCREEN = false;
2、隐藏设置中的搜索栏
布局文件:android/packages/apps/Settings/res/layout/settings_homepage_container.xml
直接GONE
隐藏掉,或者将导入search_bar布局删掉。
<com.google.android.material.appbar.AppBarLayout
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/search_bar"/>
</com.google.android.material.appbar.AppBarLayout>
释放出搜索栏原本所占用的区域,主要将SettingsHomepageActivity.java文件中setHomepageContainerPaddingTop()方法中一级菜单距离顶部设置为searchBarMargin,以保证布局的一致性。
android/packages/apps/Settings/src/com/android/settings/homepage/SettingsHomepageActivity.java
@VisibleForTesting
void setHomepageContainerPaddingTop() {
final View view = this.findViewById(R.id.homepage_container);
final int searchBarHeight = getResources().getDimensionPixelSize(R.dimen.search_bar_height);
final int searchBarMargin = getResources().getDimensionPixelSize(R.dimen.search_bar_margin);
// The top padding is the height of action bar(48dp) + top/bottom margins(16dp)
// final int paddingTop = searchBarHeight + searchBarMargin * 2;
final int paddingTop = searchBarMargin;
view.setPadding(0 /* left */, paddingTop, 0 /* right */, 0 /* bottom */);
}
3、去掉全部应用界面的搜索框
布局文件-只为记录:android/packages/apps/Launcher3/res/layout/search_container_all_apps.xml
<com.android.launcher3.allapps.search.AppsSearchContainerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/search_container_all_apps"
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_search_bar_field_height"
...
android:textSize="16sp"
android:translationY="24dp" />
源码位置
android/packages/apps/Launcher3/src/com/android/launcher3/allapps/AllAppsContainerView.java
packages/apps/Launcher3/src/com/android/launcher3/allapps/AllAppsContainerView.java
@Override
protected void onFinishInflate() {
super.onFinishInflate();
......
mSearchContainer = findViewById(R.id.search_container_all_apps);
mSearchUiManager = (SearchUiManager) mSearchContainer;
mSearchUiManager.initialize(this);
mSearchContainer.setVisibility(View.GONE); // add
}
packages/apps/Launcher3/src/com/android/launcher3/allapps/AllAppsTransitionController.java
public void setAlphas(int visibleElements, AnimationConfig config, AnimatorSetBuilder builder) {
......
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra, hasAllAppsContent, setter, headerFade, allAppsFade);
//removed
//mAppsView.getSearchUiManager().setContentVisibility(visibleElements, setter, allAppsFade);
setter.setInt(mScrimView, ScrimView.DRAG_HANDLE_ALPHA,
(visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, allAppsFade);
}