Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android 如何去除Launcher上默認的google search bar?

Android 如何去除Launcher上默認的google search bar?

編輯:關於Android編程

 

 

請參考如下改法:

1. Launcher2 eslayoutqsb_bar.xml中,

layout=@layout/search_bar

android:visibility=gone /> //加入 android:visibility=gone

 

2. Launcher2srccomandroidlauncher2SearchDropTargetBar.java 中

onFinishInflate() 方法內,將mQSBSearchBarFadeInAnim相關的部分作如下修改:

mQSBSearchBarFadeInAnim = ObjectAnimator.ofFloat(mQSBSearchBar, alpha, 0f); //最後一個參數改為 0f, 原來是 1f

mQSBSearchBarFadeInAnim.setDuration(sTransitionInDuration);

mQSBSearchBarFadeInAnim.addListener(new AnimatorListenerAdapter() {

@Override

public void onAnimationStart(Animator animation) {

mQSBSearchBar.setVisibility(View.INVISIBLE); //參數改為 View.INVISIBLE, 原來是 View.VISIBLE

 

3. 仍然是此 java 文件,將showSearchBar() 方法作如下修改:

public void showSearchBar(boolean animated) {

if (LauncherLog.DEBUG) LauncherLog.d(TAG, (SearchDropTargetBar)showSearchBar animated = + animated);

cancelAnimations();

if (animated) {

mQSBSearchBarFadeInAnim.start();

} else {

mQSBSearchBar.setVisibility(View.INVISIBLE); //參數改為:View.INVISIBLE

mQSBSearchBar.setAlpha(0f); //參數改為 0f.

}

mIsSearchBarHidden = false;

}

}

});

 

JB:

1. Launcher2 eslayoutqsb_bar.xml中,

layout=@layout/search_bar

android:visibility=gone /> //加入 android:visibility=gone

 

2. packagesappsLauncher2 eslayout-portlauncher.xml

android:id=@+id/voice_button_proxy
android:layout_width=80dp
android:layout_height=@dimen/qsb_bar_height
android:layout_gravity=top|right
android:clickable=false //modify this value to false
onClick=onClickVoiceButton
android:importantForAccessibility=no
launcher:sourceViewId=@+id/voice_button />

 

3. Launcher2srccomandroidlauncher2SearchDropTargetBar.java 中

onFinishInflate() 方法內,將mQSBSearchBarAnim 相關的部分作如下修改:

// Create the various fade animations

if (mEnableDropDownDropTargets) {

mDropTargetBar.setTranslationY(-mBarHeight);

mDropTargetBarAnim = ObjectAnimator.ofFloat(mDropTargetBar, translationY,

-mBarHeight, 0f);

mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar, translationY, -mBarHeight,

-mBarHeight); //modify 3rd para to -mBarHeight

} else {

mDropTargetBar.setAlpha(0f);

mDropTargetBarAnim = ObjectAnimator.ofFloat(mDropTargetBar, alpha, 0f, 1f);

mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar, alpha, 0f, 0f); //modify 3rd para to 0f;

}

 

4. 仍然是這只 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); //參數改為 0f;

}

}

mIsSearchBarHidden = false;

}

 


  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved