zoukankan      html  css  js  c++  java
  • 如何去除Launcher默认的google search bar?

    JB2/JB3/JB5/JB9版本:

    1. 请修改 Launcher2/res/layout/qsb_bar.xml,如下:
    <include android:id="@+id/qsb_search_bar"
    layout="@layout/search_bar"
    android:visibility="gone" />
    添加android:visibility="gone"
     
    2. 请修改Launcher2/res/layout-port/launcher.xml,如下:
    <com.android.launcher2.DrawableStateProxyView
    android:id="@+id/voice_button_proxy"
    android:layout_width="80dp"
    android:layout_height="@dimen/qsb_bar_height"
    android:layout_gravity="top|right"
    android:clickable="true"
    onClick="onClickVoiceButton"
    android:importantForAccessibility="no"
    launcher:sourceViewId="@+id/voice_button" />
    修改android:clickable="false"
     
    3. 请修改Launcher2/src/com/android/launcher2/SearchDropTargetBar.java的
    onFinishInflate() 方法,如下:
    ......
    // Create the various fade animations
    if (mEnableDropDownDropTargets) {
    mDropTargetBar.setTranslationY(-mBarHeight);
    mDropTargetBarAnim = ObjectAnimator.ofFloat(mDropTargetBar,"translationY",-mBarHeight, 0f);
    mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "translationY",-mBarHeight,-mBarHeight);
    } else {
    mDropTargetBar.setAlpha(0f);mDropTargetBarAnim = ObjectAnimator.ofFloat(mDropTargetBar, "alpha", 0f,1f);
    mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 0f,0f);
    }
    ......
     
    4. 请修改Launcher2/src/com/android/launcher2/SearchDropTargetBar.java的
    showSearchBar()方法,如下:
    public void showSearchBar(boolean animated) {
    if (!mIsSearchBarHidden) return;
    if (animated) {
    prepareStartAnimation(mQSBSearchBar);
    mQSBSearchBarAnim.reverse();
    } else {
    mQSBSearchBarAnim.cancel();
    if (mEnableDropDownDropTargets) {
    mQSBSearchBar.setTranslationY(0);
    } else {
    mQSBSearchBar.setAlpha(0f);
    }
    }
    mIsSearchBarHidden = false;
    }
     

    KK 版本:

    1. 请修改Launcher3/res/layout-port/search_bar.xml,如下:
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/resauto/
    com.android.launcher3"
    style="@style/SearchDropTargetBar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/search_frame"
    android:visibility="gone">
    添加android:visibility="gone"
    2. 请修改Launcher3/res/layout-port/launcher.xml,如下:
    <com.android.launcher3.DrawableStateProxyView
    android:id="@+id/voice_button_proxy"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_gravity="top|end"
    android:clickable="true"
    android:onClick="onClickVoiceButton"
    android:importantForAccessibility="no"
    launcher:sourceViewId="@+id/voice_button" />
    修改android:clickable="false"

    3. 请修改Launcher3/src/com/android/launcher3/SearchDropTargetBar.java的
    setup()方法,如下:
    ......
    if (mEnableDropDownDropTargets) {
    mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar,"translationY", -mBarHeight,-mBarHeight);
    } else {
    mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar,"alpha", 0f, 0f);
    }
    ......

    4. 请修改Launcher3/src/com/android/launcher3/SearchDropTargetBar.java的
    showSearchBar()方法,如下:
    public void showSearchBar(boolean animated) {
    boolean needToCancelOngoingAnimation =
    mQSBSearchBarAnim.isRunning() && !animated;
    if (!mIsSearchBarHidden && !needToCancelOngoingAnimation) return;
    if (animated) {
    prepareStartAnimation(mQSBSearchBar);
    mQSBSearchBarAnim.reverse();
    } else {
    mQSBSearchBarAnim.cancel();
    if (mEnableDropDownDropTargets) {
    mQSBSearchBar.setTranslationY(0);
    } else {
    mQSBSearchBar.setAlpha(0f);
    }
    }
    mIsSearchBarHidden = false;
    }
    5. 请修改Launcher3/src/com/android/launcher3/Workspace.java的
    getChangeStateAnimation()方法,如下:
    ......
    float finalSearchBarAlpha = !stateIsNormal ? 0f : 0f;  //默认为1f:0f
    ......
  • 相关阅读:
    [luogu T71973]卡常者π酱
    [日常] HEOI 2019 退役记
    [教程]网络流详解: 从入门到放弃
    [LOJ 6213]「美团 CodeM 决赛」radar
    [BZOJ 1568][JSOI2008]Blue Mary开公司
    [BZOJ 3167][HEOI 2013]SAO
    [BZOJ 4763]雪辉
    [LOJ 2146][BZOJ 4873][Shoi2017]寿司餐厅
    [HZNOI #koishi] Magic
    [luogu P4230]连环病原体
  • 原文地址:https://www.cnblogs.com/chendalin/p/7196353.html
Copyright © 2011-2022 走看看