下面列出了android.widget.FrameLayout#getHeight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Starts the circular reveal of the preview with an overlay above that fades out
*/
private void startCircularReveal(final FrameLayout previewView,
final View overlayView,
final View morphView) {
isMorphingToShow = true;
float startRadius = previewView.getHeight() / 2f;
float endRadius = getRadius(previewView);
long duration = morphShowDuration;
morphAnimator = ViewAnimationUtils.createCircularReveal(previewView,
getCenterX(previewView),
getCenterY(previewView),
startRadius,
endRadius);
morphAnimator.setTarget(previewView);
morphAnimator.setInterpolator(new AccelerateInterpolator());
morphAnimator.setDuration(duration);
morphAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
isMorphingToShow = false;
isShowing = false;
overlayView.setAlpha(0.0f);
overlayView.setVisibility(View.INVISIBLE);
}
});
morphAnimator.start();
previewView.setVisibility(View.VISIBLE);
overlayView.setVisibility(View.VISIBLE);
morphView.setVisibility(View.INVISIBLE);
overlayView.animate()
.alpha(0f)
.setDuration(morphShowDuration / 2);
}
private void startReverseCircularReveal(final FrameLayout previewView,
final PreviewBar previewBar,
final View overlayView,
final View morphView) {
isMorphingToHide = true;
float startRadius = getRadius(previewView);
float endRadius = previewView.getHeight() / 2f;
long duration = morphHideDuration;
morphAnimator = ViewAnimationUtils.createCircularReveal(previewView,
getCenterX(previewView),
getCenterY(previewView),
startRadius,
endRadius);
morphAnimator.setDuration(duration);
morphAnimator.setInterpolator(new AccelerateInterpolator());
morphAnimator.setTarget(previewView);
morphAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
isMorphingToHide = false;
startHideTranslation(previewView, previewBar, overlayView, morphView);
}
});
overlayView.setVisibility(View.VISIBLE);
overlayView.animate().alpha(1f).setDuration(morphHideDuration / 2)
.setInterpolator(new AccelerateInterpolator()).start();
morphAnimator.start();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup fcontainer, @Nullable Bundle savedInstanceState) {
if (savedInstanceState == null) {
getChildFragmentManager().beginTransaction()
.add(new MediaPickerFragment(), "picker")
.commitNow();
}
root = new FrameLayout(getContext()) {
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (h != oldh && shareButtons != null) {
shareButtons.getLayoutParams().height = root.getHeight() - Screen.dp(135);
shareButtons.requestLayout();
}
}
};
root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
root.setBackgroundColor(getActivity().getResources().getColor(R.color.dialog_overlay));
root.setVisibility(View.INVISIBLE);
isLoaded = false;
// messenger().getGalleryScannerActor().send(new GalleryScannerActor.Show());
// messenger().getGalleryScannerActor().send(new GalleryScannerActor.Hide());
return root;
}
public static final CurtainViewController.SlidingStatus getSlidingStatus(
CurtainViewController mCurtainViewController) {
FrameLayout slidingParent = mCurtainViewController.getSlidingParent();
FrameLayout.LayoutParams slidingLayoutParams = (FrameLayout.LayoutParams) slidingParent
.getLayoutParams();
if (mCurtainViewController.getSlidingItem().getSlidingType() == SlidingType.SIZE) {
int currentSlidingHeight = slidingParent.getHeight();
if (currentSlidingHeight == 0) {
return CurtainViewController.SlidingStatus.COLLAPSED;
} else if (currentSlidingHeight >= mCurtainViewController
.getSlidingHeight()) {
return CurtainViewController.SlidingStatus.EXPANDED;
} else {
return CurtainViewController.SlidingStatus.ANIMATING;
}
} else if (mCurtainViewController.getSlidingItem().getSlidingType() == SlidingType.MOVE) {
int currentSlidingTop = slidingLayoutParams.topMargin;
if (currentSlidingTop <= -mCurtainViewController.getSlidingHeight()) {
return CurtainViewController.SlidingStatus.COLLAPSED;
} else if (currentSlidingTop >= 0) {
return CurtainViewController.SlidingStatus.EXPANDED;
} else {
return CurtainViewController.SlidingStatus.ANIMATING;
}
} else {
return CurtainViewController.SlidingStatus.ANIMATING;
}
}
private float getMorphScale(FrameLayout previewView, View morphView) {
return (float) (previewView.getHeight() / morphView.getLayoutParams().height);
}
/**
* The destination Y of the view that'll morph into the preview
*/
private float getMorphEndY(FrameLayout previewView, View morphView) {
return (int) (previewView.getY()
+ previewView.getHeight() / 2f)
- morphView.getHeight() / 2f;
}