/** * 在SDK小于23(Android 6.0以下)时,弹出ActionMode会在状态栏位置插入一个黑色View遮挡状态栏,影响用户体验。 */ protected void fixActionModeStatusBarAbnormal() { ViewGroup contentParent = (ViewGroup) mSwipeBackActivity.findViewById(android.R.id.content).getParent(); contentParent.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { ViewGroup contentParent = (ViewGroup) v; if (contentParent.getChildCount() > 2) { contentParent.removeView(contentParent.getChildAt(2)); } } }); }
public LighterInternalImpl(ViewGroup rootView){ mRootView = rootView; mLighterView = new LighterView(rootView.getContext()); mRootView.addOnLayoutChangeListener(mRootViewLayoutChangeListener); }
void show() { addToParent(); mView.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mView.removeOnLayoutChangeListener(this); mView.setTranslationY(mView.getHeight() + getLayoutParams().bottomMargin); Animator animator = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y, 0); animator.setInterpolator(new DecelerateInterpolator()); animator.setDuration(mAnimationDuration); startAnimatorOnSurfaceView(animator); } }); }
/** * 返回窗口背景视图,用于覆盖当输入法及导航栏变化时底部的黑色 * <p> * 因{android:windowBackground}透明,输入法及导航栏变化时底部为黑色 */ public View getWindowBackGroundView(ViewGroup decorView) { if (mWindowBackGroundView == null && mWindowBackgroundColor >>> 24 > 0) { mWindowBackGroundView = new View(mSwipeBackActivity); mWindowBackGroundView.setTranslationY(decorView.getHeight()); mWindowBackGroundView.setBackgroundColor(mWindowBackgroundColor); decorView.addView(mWindowBackGroundView, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); //监听DecorView的布局变化 mDecorView.addOnLayoutChangeListener(mPrivateListener); } return mWindowBackGroundView; }
private void hideBottomBar() { if (mBottomBarView == null) return; ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.BOTTOM; final ViewGroup compositorView = mActivity.getCompositorViewHolder(); compositorView.addView(mBottomBarView, lp); compositorView.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { compositorView.removeOnLayoutChangeListener(this); mBottomBarView.animate().alpha(0f).translationY(mBottomBarView.getHeight()) .setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE) .setDuration(SLIDE_ANIMATION_DURATION_MS) .withEndAction(new Runnable() { @Override public void run() { ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView); mBottomBarView = null; } }).start(); } }); }
mDecorView.addOnLayoutChangeListener(mPrivateListener);
private void addToParent() { // LayoutParams in CoordinatorLayout and FrameLayout cannot be used interchangeably. Thus // we create new LayoutParams every time. if (mParent instanceof CoordinatorLayout) { CoordinatorLayout.LayoutParams lp = new LayoutParams(getLayoutParams()); lp.gravity = Gravity.BOTTOM | Gravity.START; lp.setBehavior(mBehavior); mParent.addView(mView, lp); } else if (mParent instanceof FrameLayout) { FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(getLayoutParams()); lp.gravity = Gravity.BOTTOM | Gravity.START; mParent.addView(mView, lp); } else { assert false : "Only FrameLayout and CoordinatorLayout are supported to show snackbars"; } // Why setting listener on parent? It turns out that if we force a relayout in the layout // change listener of the view itself, the force layout flag will be reset to 0 when // layout() returns. Therefore we have to do request layout on one level above the requested // view. mParent.addOnLayoutChangeListener(mLayoutListener); }
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mRequestView.addOnLayoutChangeListener(new FadeInAnimator()); mRequestView.addOnLayoutChangeListener(new PeekingAnimator());
public QSAnimator(ViewGroup container, QuickQSPanel quickPanel, ViewGroup panel) { mContext = container.getContext(); mQsContainer = container; mQuickQsPanel = quickPanel; mQsPanel = panel; mQsPanel.addOnAttachStateChangeListener(this); container.addOnLayoutChangeListener(this); mPagedLayout = StatusBarHeaderHooks.qsHooks.getTileLayout(); mPagedLayout.setPageListener(this); if (ConfigUtils.qs().fix_header_space && !mReconfigureNotificationPanel) { ResourceUtils res = ResourceUtils.getInstance(container.getContext()); mQsTopAdjustment = res.getDimensionPixelSize(R.dimen.qs_margin_top) - res.getDimensionPixelSize(R.dimen.status_bar_header_height); } }
mRoot.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom
keyboardView.attachTo(editText); ViewGroup rootView = activity.getWindow().getDecorView().findViewById(android.R.id.content); rootView.addOnLayoutChangeListener(onLayoutChangeListener); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
mBubblePopupWindow.setPadding(dp2px(mSeekbarPadding.getProgress())); mActivityPopupWindowSample.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { private int savedHeight = 0;
mRequestView.addOnLayoutChangeListener(new SheetEnlargingAnimator(true));
public void showSoftKeyboard(EditText editText) { // mRootView.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener); mRootView.addOnLayoutChangeListener(mOnLayoutChangeListener); BaseKeyboard keyboard = getBindKeyboard(editText); if (keyboard == null) { Log.e(TAG, "edit text not bind to keyboard"); return; } keyboard.setEditText(editText); keyboard.setNextFocusView(mKeyboardWithSearchView.getEditText()); initKeyboard(keyboard); mKeyboardWithSearchView.getKeyboadViewContainer().setPadding(Utils.dipToPx(mContext, keyboard.getPadding().left), Utils.dipToPx(mContext, keyboard.getPadding().top), Utils.dipToPx(mContext, keyboard.getPadding().right), Utils.dipToPx(mContext, keyboard.getPadding().bottom)); if(mRootView.indexOfChild(mKeyboardWithSearchView) == -1) { mRootView.addView(mKeyboardWithSearchView, mKeyboardContainerLayoutParams); }else { mKeyboardWithSearchView.setVisibility(View.VISIBLE); } mKeyboardWithSearchView.setAnimation(AnimationUtils.loadAnimation(mContext, R.anim.down_to_up)); }
mButtonBar.setVisibility(View.VISIBLE); mRequestView.removeView(mSpinnyLayout); mRequestView.addOnLayoutChangeListener(new SheetEnlargingAnimator(false));