本文整理了Java中android.view.View.addOnLayoutChangeListener()
方法的一些代码示例,展示了View.addOnLayoutChangeListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。View.addOnLayoutChangeListener()
方法的具体详情如下:
包路径:android.view.View
类名称:View
方法名:addOnLayoutChangeListener
暂无
代码示例来源:origin: nickbutcher/plaid
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (sheet != null) {
throw new UnsupportedOperationException("BottomSheet must only have 1 child view");
}
sheet = child;
sheetOffsetHelper = new ViewOffsetHelper(sheet);
sheet.addOnLayoutChangeListener(sheetLayout);
// force the sheet contents to be gravity bottom. This ain't a top sheet.
((LayoutParams) params).gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
super.addView(child, index, params);
}
代码示例来源:origin: ZieIony/Carbon
private void addListeners() {
if (dependency == null)
return;
if (dependency instanceof TransformationView)
((TransformationView) dependency).addOnTransformationChangedListener(transformationListener);
dependency.addOnLayoutChangeListener(layoutListener);
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void initViews(View rootView) {
super.initViews(rootView);
resizingIndicator = rootView.findViewById(R.id.resizing_indicator);
fullScreenButton = rootView.findViewById(R.id.fullScreenButton);
fullScreenButton.setOnClickListener(v -> onFullScreenButtonClicked());
videoPlayPause = rootView.findViewById(R.id.videoPlayPause);
extraOptionsView = rootView.findViewById(R.id.extraOptionsView);
closingOverlayView = rootView.findViewById(R.id.closingOverlay);
rootView.addOnLayoutChangeListener(this);
}
代码示例来源:origin: stackoverflow.com
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Inflate the layout for this fragment
final View view = inflater.inflate(R.layout.fragment_map_list, container, false);
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);
toggleInformationView(view);
}
});
}
return view;
}
代码示例来源:origin: ZieIony/Carbon
@Override
public void setContentView(@NonNull View view, ViewGroup.LayoutParams params) {
contentView = view;
contentView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
onContentHeightChanged(contentView.getHeight());
});
container.addView(view);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void onVideoSizeChanged(
int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
float videoAspectRatio =
(height == 0 || width == 0) ? 1 : (width * pixelWidthHeightRatio) / height;
if (surfaceView instanceof TextureView) {
// Try to apply rotation transformation when our surface is a TextureView.
if (unappliedRotationDegrees == 90 || unappliedRotationDegrees == 270) {
// We will apply a rotation 90/270 degree to the output texture of the TextureView.
// In this case, the output video's width and height will be swapped.
videoAspectRatio = 1 / videoAspectRatio;
}
if (textureViewRotation != 0) {
surfaceView.removeOnLayoutChangeListener(this);
}
textureViewRotation = unappliedRotationDegrees;
if (textureViewRotation != 0) {
// The texture view's dimensions might be changed after layout step.
// So add an OnLayoutChangeListener to apply rotation after layout step.
surfaceView.addOnLayoutChangeListener(this);
}
applyTextureViewRotation((TextureView) surfaceView, textureViewRotation);
}
onContentAspectRatioChanged(videoAspectRatio, contentFrame, surfaceView);
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void initListeners() {
super.initListeners();
PlayerGestureListener listener = new PlayerGestureListener();
gestureDetector = new GestureDetector(context, listener);
gestureDetector.setIsLongpressEnabled(false);
getRootView().setOnTouchListener(listener);
queueButton.setOnClickListener(this);
repeatButton.setOnClickListener(this);
shuffleButton.setOnClickListener(this);
playPauseButton.setOnClickListener(this);
playPreviousButton.setOnClickListener(this);
playNextButton.setOnClickListener(this);
moreOptionsButton.setOnClickListener(this);
toggleOrientationButton.setOnClickListener(this);
switchBackgroundButton.setOnClickListener(this);
switchPopupButton.setOnClickListener(this);
getRootView().addOnLayoutChangeListener((view, l, t, r, b, ol, ot, or, ob) -> {
if (l != ol || t != ot || r != or || b != ob) {
// Use smaller value to be consistent between screen orientations
// (and to make usage easier)
int width = r - l, height = b - t;
maxGestureLength = (int) (Math.min(width, height) * MAX_GESTURE_LENGTH);
if (DEBUG) Log.d(TAG, "maxGestureLength = " + maxGestureLength);
volumeProgressBar.setMax(maxGestureLength);
brightnessProgressBar.setMax(maxGestureLength);
setInitialGestureValues();
}
});
}
代码示例来源:origin: Flipboard/bottomsheet
sheetView.addOnLayoutChangeListener(sheetViewOnLayoutChangeListener);
代码示例来源:origin: stackoverflow.com
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Inflate the layout for this fragment
final View view = inflater.inflate(R.layout.fragment_map_list, container, false);
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);
revealView(view);
}
});
}
return view;
}
代码示例来源:origin: florent37/ExpansionPanel
@Override
public boolean onPreDraw() {
childView.getViewTreeObserver().removeOnPreDrawListener(this);
//now we have a size
if (expanded) {
expand(false);
}
childView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (expanded && animator == null) {
final int width = right - left;
post(new Runnable() {
@Override
public void run() {
setWidth(width);
}
});
}
}
});
return false;
}
});
代码示例来源:origin: florent37/ExpansionPanel
@Override
public boolean onPreDraw() {
childView.getViewTreeObserver().removeOnPreDrawListener(this);
//now we have a size
if (expanded) {
expand(false);
}
childView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (expanded && animator == null) {
final int height = bottom - top;
post(new Runnable() {
@Override
public void run() {
setHeight(height);
}
});
}
}
});
return true;
}
});
代码示例来源:origin: stackoverflow.com
final View dropDownAnchor = searchView.findViewById(searchEditText.getDropDownAnchor());
if (dropDownAnchor != null) {
dropDownAnchor.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
代码示例来源:origin: ribot/ribot-app-android
mProfileInfoLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
代码示例来源:origin: org.boofcv/boofcv-android
protected void startCameraView( View view) {
if( verbose )
Log.i(TAG,"startCamera(View="+(view!=null)+")");
this.mView = view;
this.mTextureView = null;
view.addOnLayoutChangeListener(mViewLayoutChangeListener);
}
代码示例来源:origin: lovejjfg/UCPullRefresh
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (sheet != null) {
throw new UnsupportedOperationException("CurveLayout must only have 1 child view");
}
sheet = child;
sheet.addOnLayoutChangeListener(sheetLayout);
// force the sheet contents to be gravity bottom. This ain't a top sheet.
((LayoutParams) params).gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
super.addView(child, index, params);
}
代码示例来源:origin: cpiz/BubbleView
private void setArrowToRef(View targetView) {
if (mArrowToViewRef != null) {
View oldTargetView = mArrowToViewRef.get();
if (oldTargetView != null) {
oldTargetView.removeOnLayoutChangeListener(mOnLayoutChangeListener);
}
}
mArrowToViewRef = targetView != null ? new WeakReference<>(targetView) : null;
if (targetView != null) {
targetView.addOnLayoutChangeListener(mOnLayoutChangeListener);
}
}
代码示例来源:origin: lovejjfg/UCPullRefresh
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (sheet != null) {
throw new UnsupportedOperationException("CurveLayout must only have 1 child view");
}
sheet = child;
sheetOffsetHelper = new ViewOffsetHelper(sheet);
sheet.addOnLayoutChangeListener(sheetLayout);
// force the sheet contents to be gravity bottom. This ain't a top sheet.
((LayoutParams) params).gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
super.addView(child, index, params);
}
代码示例来源:origin: rockon999/LeanbackLauncher
public void onViewAttachedToWindow(final VH holder) {
super.onViewAttachedToWindow(holder);
if ((this.mContext instanceof MainActivity) && ((MainActivity) this.mContext).isLaunchAnimationInProgress()) {
holder.itemView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
v.removeOnLayoutChangeListener(this);
((MainActivity) RowViewAdapter.this.mContext).includeInLaunchAnimation(holder.itemView);
}
});
}
}
}
代码示例来源:origin: derry/delion
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (mNavigationButton != null) mNavigationButton.addOnLayoutChangeListener(this);
if (mUrlBar != null) mUrlBar.addOnLayoutChangeListener(this);
if (mLocationBar != null) {
mLocationBar.getContainerView().addOnLayoutChangeListener(this);
}
getRootView().addOnLayoutChangeListener(this);
}
代码示例来源:origin: AlexMofer/ProjectX
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);
}
内容来源于网络,如有侵权,请联系作者删除!