List of usage examples for android.view View addOnLayoutChangeListener
public void addOnLayoutChangeListener(OnLayoutChangeListener listener)
From source file:com.zzc.androidtrain.view.refresh.Utils.java
public static void intPreScroll(final SmoothAppBarLayout smoothAppBarLayout, final View target, final int offset) { target.addOnLayoutChangeListener(new OnPreScrollListener(smoothAppBarLayout, target, offset)); }
From source file:despotoski.nikola.github.com.bottomnavigationlayout.Util.java
public static void runOnAttachedToLayout(View v, final Runnable runnable) { if (ViewCompat.isLaidOut(v)) runnable.run();// ww w .ja va2 s. co m else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { v.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { runnable.run(); v.removeOnLayoutChangeListener(this); } }); return; } final ViewTreeObserver viewTreeObserver = v.getViewTreeObserver(); if (viewTreeObserver != null && viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { runnable.run(); if (viewTreeObserver.isAlive()) //noinspection deprecation viewTreeObserver.removeGlobalOnLayoutListener(this); } }); } } }
From source file:com.redbooth.projectnevada.CardGridFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_card_grid, container, false); view.addOnLayoutChangeListener(onLayoutChangeListener); ButterKnife.inject(this, view); return view;/*from w w w . j a v a2 s . co m*/ }
From source file:com.rockspoon.rockandui.Components.RelativeLayoutWithSwipe.java
public void setTopView(View view) { id = view.getId();// w w w. java 2s . com 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 (isMoving()) { v.setTop(oldTop); v.setBottom(oldBottom); v.setLeft(oldLeft); v.setRight(oldRight); } } }); }
From source file:com.brettyin.cardshelper.fragment.SignInFragment.java
@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//from w w w . j a v a 2 s . c o m 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; }
From source file:tech.salroid.filmy.fragment.FullReadFragment.java
@Nullable @Override// ww w.j a v a 2 s. c o m public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.read_full_layout, container, false); ButterKnife.bind(this, view); crossButton.setOnClickListener(this); // To run the animation as soon as the view is layout in the view hierarchy we add this // listener and remove it // as soon as it runs to prevent multiple animations if the view changes bounds 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); int cx = getArguments().getInt("cx"); int cy = getArguments().getInt("cy"); // get the hypothenuse so the radius is from one corner to the other int radius = (int) Math.hypot(right, bottom); Animator reveal; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius); reveal.setInterpolator(new DecelerateInterpolator(2f)); reveal.setDuration(1000); reveal.start(); } } }); return view; }
From source file:com.simas.vc.nav_drawer.NavDrawerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mDrawerList = (HeadlessListView) inflater.inflate(R.layout.fragment_navigation_drawer, container, false); final View header = createHeader(inflater, mDrawerList); // When available, fetch the item width and height if (MainActivity.sPreviewSize == 0) { header.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override// ww w .j a v a2 s . co m public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { int width = header.getWidth(), height = header.getHeight(); if (width > 0 && height > 0) { header.removeOnLayoutChangeListener(this); MainActivity.sPreviewSize = (width > height) ? width : height; } } }); } getListView().addHeaderView(header); return mDrawerList; }
From source file:tech.salroid.filmy.fragment.AllTrailerFragment.java
@Nullable @Override/*from w w w . ja v a2s.com*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); nightMode = sp.getBoolean("dark", false); View view = inflater.inflate(R.layout.all_trailer_layout, container, false); ButterKnife.bind(this, view); if (!nightMode) allThemeLogic(); else { nightModeLogic(); } crossButton.setOnClickListener(this); // To run the animation as soon as the view is layout in the view hierarchy we add this // listener and remove it // as soon as it runs to prevent multiple animations if the view changes bounds 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); int cx = getArguments().getInt("cx"); int cy = getArguments().getInt("cy"); // get the hypothenuse so the radius is from one corner to the other int radius = (int) Math.hypot(right, bottom); Animator reveal; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius); reveal.setInterpolator(new DecelerateInterpolator(2f)); reveal.setDuration(1000); reveal.start(); } } }); init(view); return view; }
From source file:com.huyn.demogroup.freechild.FixedViewAttacher.java
public FixedViewAttacher(ImageView imageView) { mImageView = imageView;//from w w w . j av a 2 s .c o m if (imageView.isInEditMode()) { return; } View parent = (View) mImageView.getParent(); parent.setOnTouchListener(this); parent.addOnLayoutChangeListener(this); // Create Gesture Detectors... mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mSingleFlingListener != null) { if (getScale() > DEFAULT_MIN_SCALE) { return false; } if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) { return false; } return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY); } return false; } }); }
From source file:net.simonvt.cathode.ui.fragment.EpisodeFragment.java
@Override public void onViewCreated(View view, Bundle inState) { super.onViewCreated(view, inState); ButterKnife.inject(this, view); if (!isTablet) { toolbar.setNavigationIcon(R.drawable.ic_arrow_back); }/*ww w. j a v a 2 s . co m*/ toolbar.setNavigationOnClickListener(navigationClickListener); createMenu(toolbar); toolbar.setOnMenuItemClickListener(menuClickListener); updateTitle(); 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); } if (!isTablet && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { content.setScrollY(screenshot.getHeight() / 2); } } }); rating.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { RatingDialog.newInstance(RatingDialog.Type.EPISODE, episodeId, currentRating) .show(getFragmentManager(), DIALOG_RATING); } }); if (!isTablet) { content.setListener(new ObservableScrollView.ScrollListener() { @Override public void onScrollChanged(int l, int t) { final int offset = (int) (t / 2.0f); screenshot.setTranslationY(offset); } }); } }