Java Code Examples for android.view.View#addOnLayoutChangeListener()
The following examples show how to use
android.view.View#addOnLayoutChangeListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomTabBottomBarDelegate.java From 365browser with Apache License 2.0 | 6 votes |
private void showRemoteViews(RemoteViews remoteViews) { final View inflatedView = remoteViews.apply(mActivity, getBottomBarView()); if (mClickableIDs != null && mClickPendingIntent != null) { for (int id: mClickableIDs) { if (id < 0) return; View view = inflatedView.findViewById(id); if (view != null) view.setOnClickListener(mBottomBarClickListener); } } getBottomBarView().addView(inflatedView, 1); inflatedView.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) { inflatedView.removeOnLayoutChangeListener(this); mFullscreenManager.setBottomControlsHeight(v.getHeight()); } }); }
Example 2
Source File: OriginPoint.java From tns-core-modules-widgets with Apache License 2.0 | 6 votes |
private static PivotSetter getSetter(View view) { PivotSetter setter = null; if (layoutListeners == null) { layoutListeners = new WeakHashMap<>(); } else { setter = layoutListeners.get(view); } if (setter == null) { setter = new PivotSetter(); view.addOnLayoutChangeListener(setter); layoutListeners.put(view, setter); } return setter; }
Example 3
Source File: ReactViewGroup.java From react-native-GPay with MIT License | 6 votes |
void addViewWithSubviewClippingEnabled( View child, int index, ViewGroup.LayoutParams params) { Assertions.assertCondition(mRemoveClippedSubviews); Assertions.assertNotNull(mClippingRect); Assertions.assertNotNull(mAllChildren); addInArray(child, index); // we add view as "clipped" and then run {@link #updateSubviewClipStatus} to conditionally // attach it int childIndexOffset = 0; for (int i = 0; i < index; i++) { if (!isChildInViewGroup(mAllChildren[i])) { childIndexOffset++; } } updateSubviewClipStatus(mClippingRect, index, childIndexOffset); child.addOnLayoutChangeListener(mChildrenLayoutChangeListener); }
Example 4
Source File: ViewNatrueTransitionAnimActivity.java From AndroidStudyDemo with GNU General Public License v2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final View view = getLayoutInflater().inflate(R.layout.activity_viewnatruetransitionanim, null); view.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) { v.removeOnLayoutChangeListener(this); mHalfHeight = view.getHeight() / 2; mEditModeContainerFL.setTranslationY(mHalfHeight); mEditModeContainerFL.setAlpha(0f); mCustomAnimator.setEditModeHalfHeight(mHalfHeight); } }); setContentView(view); initView(); initListener(); }
Example 5
Source File: HeadersFragment.java From adt-leanback-support with Apache License 2.0 | 6 votes |
@Override public void onCreate(ItemBridgeAdapter.ViewHolder viewHolder) { View headerView = viewHolder.getViewHolder().view; headerView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mOnHeaderClickedListener != null) { mOnHeaderClickedListener.onHeaderClicked(); } } }); headerView.setFocusable(true); headerView.setFocusableInTouchMode(true); if (mWrapper != null) { viewHolder.itemView.addOnLayoutChangeListener(sLayoutChangeListener); } else { headerView.addOnLayoutChangeListener(sLayoutChangeListener); } }
Example 6
Source File: TabLayout.java From material-components-android with Apache License 2.0 | 6 votes |
private void addOnLayoutChangeListener(@Nullable final View view) { if (view == null) { return; } view.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) { if (view.getVisibility() == VISIBLE) { tryUpdateBadgeDrawableBounds(view); } } }); }
Example 7
Source File: HeadersSupportFragment.java From adt-leanback-support with Apache License 2.0 | 6 votes |
@Override public void onCreate(ItemBridgeAdapter.ViewHolder viewHolder) { View headerView = viewHolder.getViewHolder().view; headerView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mOnHeaderClickedListener != null) { mOnHeaderClickedListener.onHeaderClicked(); } } }); headerView.setFocusable(true); headerView.setFocusableInTouchMode(true); if (mWrapper != null) { viewHolder.itemView.addOnLayoutChangeListener(sLayoutChangeListener); } else { headerView.addOnLayoutChangeListener(sLayoutChangeListener); } }
Example 8
Source File: ProgressFragment.java From cathode with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle inState) { super.onViewCreated(view, inState); content = Views.findRequired(view, R.id.contentContainer); progress = Views.findRequired(view, R.id.progressContainer); wait = true; view.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) { v.removeOnLayoutChangeListener(this); wait = false; if (currentState == STATE_CONTENT_VISIBLE) { content.setAlpha(1.0f); content.setVisibility(View.VISIBLE); progress.setVisibility(View.GONE); } else { content.setVisibility(View.GONE); progress.setAlpha(1.0f); progress.setVisibility(View.VISIBLE); } } }); }
Example 9
Source File: ViewUtils.java From px-android with MIT License | 5 votes |
public static void runWhenViewIsFullyMeasured(@NonNull final View view, @NonNull final Runnable runnable) { if (ViewCompat.isLaidOut(view)) { runnable.run(); } else { view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(final View v, final int left, final int top, final int right, final int bottom, final int oldLeft, final int oldTop, final int oldRight, final int oldBottom) { view.removeOnLayoutChangeListener(this); runnable.run(); } }); } }
Example 10
Source File: OverlayPanelTextViewInflater.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); View view = getView(); view.addOnLayoutChangeListener(this); }
Example 11
Source File: TooltipDrawable.java From material-components-android with Apache License 2.0 | 5 votes |
/** * Should be called to allow this drawable to calculate its position within the current display * frame. This allows it to apply to specified window padding. * * @see #detachView(View) */ public void setRelativeToView(@Nullable View view) { if (view == null) { return; } updateLocationOnScreen(view); // Listen for changes that indicate the view has moved so the location can be updated view.addOnLayoutChangeListener(attachedViewLayoutChangeListener); }
Example 12
Source File: OverlayPanelTextViewInflater.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); View view = getView(); view.addOnLayoutChangeListener(this); }
Example 13
Source File: SignInFragment.java From CoolSignIn with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { final View contentView = inflater.inflate(R.layout.fragment_sign_in, container, false); contentView.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) { v.removeOnLayoutChangeListener(this); setUpGridView(getView()); } }); return contentView; }
Example 14
Source File: AbstractPowerMenu.java From PowerMenu with Apache License 2.0 | 5 votes |
/** * shows circular revealed animation to a view. * * @param targetView view for animation target. */ private void circularRevealed(View targetView) { targetView.addOnLayoutChangeListener( new View.OnLayoutChangeListener() { @Override public void onLayoutChange( View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { view.removeOnLayoutChangeListener(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Animator animator = ViewAnimationUtils.createCircularReveal( view, (view.getLeft() + view.getRight()) / 2, (view.getTop() + view.getBottom()) / 2, 0f, Math.max(view.getWidth(), view.getHeight())); animator.setDuration(900); animator.start(); } } }); }
Example 15
Source File: ReactViewGroup.java From react-native-GPay with MIT License | 5 votes |
@Override public void setRemoveClippedSubviews(boolean removeClippedSubviews) { if (removeClippedSubviews == mRemoveClippedSubviews) { return; } mRemoveClippedSubviews = removeClippedSubviews; if (removeClippedSubviews) { mClippingRect = new Rect(); ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect); mAllChildrenCount = getChildCount(); int initialSize = Math.max(12, mAllChildrenCount); mAllChildren = new View[initialSize]; mChildrenLayoutChangeListener = new ChildrenLayoutChangeListener(this); for (int i = 0; i < mAllChildrenCount; i++) { View child = getChildAt(i); mAllChildren[i] = child; child.addOnLayoutChangeListener(mChildrenLayoutChangeListener); } updateClippingRect(); } else { // Add all clipped views back, deallocate additional arrays, remove layoutChangeListener Assertions.assertNotNull(mClippingRect); Assertions.assertNotNull(mAllChildren); Assertions.assertNotNull(mChildrenLayoutChangeListener); for (int i = 0; i < mAllChildrenCount; i++) { mAllChildren[i].removeOnLayoutChangeListener(mChildrenLayoutChangeListener); } getDrawingRect(mClippingRect); updateClippingToRect(mClippingRect); mAllChildren = null; mClippingRect = null; mAllChildrenCount = 0; mChildrenLayoutChangeListener = null; } }
Example 16
Source File: AnimationUtils.java From SearchPreference with MIT License | 5 votes |
public static void registerCircularRevealAnimation(final Context context, final View view, final RevealAnimationSetting revealSettings) { final int startColor = revealSettings.getColorAccent(); final int endColor = getBackgroundColor(view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); view.setVisibility(View.VISIBLE); int cx = revealSettings.getCenterX(); int cy = revealSettings.getCenterY(); int width = revealSettings.getWidth(); int height = revealSettings.getHeight(); int duration = context.getResources().getInteger(android.R.integer.config_longAnimTime); //Simply use the diagonal of the view float finalRadius = (float) Math.sqrt(width * width + height * height); Animator anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius).setDuration(duration); anim.setInterpolator(new FastOutSlowInInterpolator()); anim.start(); startColorAnimation(view, startColor, endColor, duration); } }); } }
Example 17
Source File: FloatingActionModeHelper.java From ProjectX with Apache License 2.0 | 5 votes |
public FloatingActionModeHelper(FloatingActionMode mode, View target, FloatingActionMode.Callback callback, int themeResId) { mMode = mode; mTarget = target; mCallback = callback; final Context context = target.getContext(); mMenu = new FloatingMenuImpl(target.getContext()); mView = new ViewManager(context, themeResId, mode, mMenu, callback); final View root = mTarget.getRootView(); root.addOnLayoutChangeListener(this); root.addOnAttachStateChangeListener(this); mTarget.addOnAttachStateChangeListener(this); }
Example 18
Source File: BuggyVideoDriverPreventer.java From no-player with Apache License 2.0 | 4 votes |
private void attemptToCorrectMediaPlayerStatus(NoPlayer player, View containerView) { preventerListener = new OnPotentialBuggyDriverLayoutListener(player); containerView.addOnLayoutChangeListener(preventerListener); }
Example 19
Source File: Utils.java From smooth-app-bar-layout with Apache License 2.0 | 4 votes |
public static void intPreScroll(final SmoothAppBarLayout smoothAppBarLayout, final View target, final int offset) { target.addOnLayoutChangeListener(new OnPreScrollListener(smoothAppBarLayout, target, offset)); }
Example 20
Source File: KeyboardListener.java From FriendBook with GNU General Public License v3.0 | 2 votes |
/** * * @param bottomChangeView 一个在软件盘弹出是bottom会发生改变的View,如:被软件键盘向上顶的View,布局的根View。如果没有监听到,说明该View的bottom值没有随软键盘的弹出而改变 * @param onKeyboardListener */ public static void setListener(View bottomChangeView, OnKeyboardListener onKeyboardListener) { bottomChangeView.addOnLayoutChangeListener(new KeyboardListener(bottomChangeView, onKeyboardListener)); }