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" />
<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" />
<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);
}
......
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;
}
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">
<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" />
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
......