onfinishinflate

时间:2024-11-09 07:00:14编辑:阿星

Android如何去除Launcher上默认的googlesearchbar

请参考如下改法:

1. Launcher2 eslayoutqsb_bar.xml中,

<include android:id="@+id/qsb_search_bar"

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中,

<include android:id="@+id/qsb_search_bar"

layout="@layout/search_bar"

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

2. packagesappsLauncher2 eslayout-portlauncher.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="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;

}


android大牛帮忙解答一下View的生命周期过程。onattachwindow在什么时候调用之

onFinishInflate() 当View中所有的子控件均被映射成xml后触发
onMeasure(int, int) 确定所有子元素的大小
onLayout(boolean, int, int, int, int) 当View分配所有的子元素的大小和位置时触发
onSizeChanged(int, int, int, int) 当view的大小发生变化时触发
onDraw(Canvas) view渲染内容的细节
onKeyDown(int, KeyEvent) 有按键按下后触发
onKeyUp(int, KeyEvent) 有按键按下后弹起时触发
onTrackballEvent(MotionEvent) 轨迹球事件
onTouchEvent(MotionEvent) 触屏事件
onFocusChanged(boolean, int, Rect) 当View获取或失去焦点时触发
onWindowFocusChanged(boolean) 当窗口包含的view获取或失去焦点时触发
onAttachedToWindow() 当view被附着到一个窗口时触发
onDetachedFromWindow() 当view离开附着的窗口时触发,Android123提示该方法和 onAttachedToWindow() 是相反的。
onWindowVisibilityChanged(int) 当窗口中包含的可见的view发生变化时触发


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

请参考如下改法:
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\src\com\android\launcher2\SearchDropTargetBar.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\res\layout\qsb_bar.xml中,
<include android:id="@+id/qsb_search_bar"
layout="@layout/search_bar"
android:visibility="gone" /> //加入 android:visibility="gone"
2. packages\apps\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=" false " //modify this value to false
onClick="onClickVoiceButton"
android:importantForAccessibility="no"
launcher:sourceViewId="@+id/voice_button" />
3. Launcher2\src\com\android\launcher2\SearchDropTargetBar.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;
}


上一篇:远远的阳光房

下一篇:没有了