本文整理汇总了Java中com.flipboard.bottomsheet.ViewTransformer类的典型用法代码示例。如果您正苦于以下问题:Java ViewTransformer类的具体用法?Java ViewTransformer怎么用?Java ViewTransformer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ViewTransformer类属于com.flipboard.bottomsheet包,在下文中一共展示了ViewTransformer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getViewTransformer
import com.flipboard.bottomsheet.ViewTransformer; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ViewTransformer getViewTransformer() {
return null;
}
示例2: getViewTransformer
import com.flipboard.bottomsheet.ViewTransformer; //导入依赖的package包/类
@Override
public ViewTransformer getViewTransformer()
{
final float targetSizeWhenBottomSheetExpanded=getResources().getDimensionPixelSize(R.dimen.moving_image_expanded_bottom_sheet_size);
final float startSizeWhenBottomSheetCollapsed=getResources().getDimensionPixelSize(R.dimen.moving_image_collapsed_bottom_sheet_size);
final float startMarginBottom=getResources().getDimensionPixelSize(R.dimen.moving_image_expanded_bottom_sheet_margin_bottom);
return new BaseViewTransformer()
{
boolean init=false;
float mOriginalContactPhotoXCoordinate;
float mOriginalBottomSheetBackgroundImageViewY;
float scaleDiff;
@Override
public void transformView(final float translation,final float maxTranslation,final float peekedTranslation,final BottomSheetLayout parent,final View view)
{
if(!init)
{
mOriginalBottomSheetBackgroundImageViewY=mMovingImageviewSize/2;
mOriginalContactPhotoXCoordinate=mMovingIconImageView.getX();
scaleDiff=(startSizeWhenBottomSheetCollapsed-targetSizeWhenBottomSheetExpanded)/startSizeWhenBottomSheetCollapsed;
init=true;
}
if(translation<mBottomSheetHeightPeeked)
{
//hidden<->peeked or hidden
reportState(translation==0?BottomSheetState.HIDDEN:BottomSheetState.HIDDEN_PEEKED);
return;
}
if(translation==mBottomSheetHeightPeeked)
{
//peek
reportState(BottomSheetState.PEEKED);
}
else
{
//peek->expand
reportState(translation==maxTranslation?BottomSheetState.EXPANDED:BottomSheetState.PEEKED_EXPANDED);
}
float progress=(translation-mBottomSheetHeightPeeked)/(maxTranslation-mBottomSheetHeightPeeked);
mMovingIconImageView.setX(mOriginalContactPhotoXCoordinate-progress*(mOriginalContactPhotoXCoordinate-mMovingImageExpandedBottomSheetMarginLeft));
final float scaleForImageView=1-progress*scaleDiff;
mMovingIconImageView.setScaleX(scaleForImageView);
mMovingIconImageView.setScaleY(scaleForImageView);
final float newMovingIconImageViewY=progress*(mBottomSheetHeightExpanded-startMarginBottom-mMovingIconImageView.getHeight()*scaleForImageView);
mMovingIconImageView.setY(newMovingIconImageViewY);
final float newBottomSheetBackgroundImageContainerY=mOriginalBottomSheetBackgroundImageViewY*(1-progress);
mBottomSheetBackgroundImageView.setY(newBottomSheetBackgroundImageContainerY);
}
};
}
示例3: getViewTransformer
import com.flipboard.bottomsheet.ViewTransformer; //导入依赖的package包/类
@Override
public ViewTransformer getViewTransformer() {
final float targetSizeWhenBottomSheetExpanded = getResources().getDimensionPixelSize(R.dimen.moving_image_expanded_bottom_sheet_size);
final float startSizeWhenBottomSheetCollapsed = getResources().getDimensionPixelSize(R.dimen.moving_image_collapsed_bottom_sheet_size);
final float startMarginBottom = getResources().getDimensionPixelSize(R.dimen.moving_image_expanded_bottom_sheet_margin_bottom);
return new BaseViewTransformer() {
boolean init = false;
float mOriginalContactPhotoXCoordinate;
float mOriginalBottomSheetBackgroundImageViewY;
float scaleDiff;
@Override
public void transformView(final float translation, final float maxTranslation, final float peekedTranslation, final BottomSheetLayout parent, final View view) {
if (!init) {
mOriginalBottomSheetBackgroundImageViewY = mMovingImageviewSize / 2;
mOriginalContactPhotoXCoordinate = mMovingIconImageView.getX();
scaleDiff = (startSizeWhenBottomSheetCollapsed - targetSizeWhenBottomSheetExpanded) / startSizeWhenBottomSheetCollapsed;
init = true;
}
if (translation < mBottomSheetHeightPeeked) {
//hidden<->peeked or hidden
reportState(translation == 0 ? BottomSheetState.HIDDEN : BottomSheetState.HIDDEN_PEEKED);
return;
}
if (translation == mBottomSheetHeightPeeked) {
//peek
reportState(BottomSheetState.PEEKED);
} else {
//peek->expand
reportState(translation == maxTranslation ? BottomSheetState.EXPANDED : BottomSheetState.PEEKED_EXPANDED);
}
float progress = (translation - mBottomSheetHeightPeeked) / (maxTranslation - mBottomSheetHeightPeeked);
mMovingIconImageView.setX(mOriginalContactPhotoXCoordinate - progress * (mOriginalContactPhotoXCoordinate - mMovingImageExpandedBottomSheetMarginLeft));
final float scaleForImageView = 1 - progress * scaleDiff;
mMovingIconImageView.setScaleX(scaleForImageView);
mMovingIconImageView.setScaleY(scaleForImageView);
final float newMovingIconImageViewY = progress * (mBottomSheetHeightExpanded - startMarginBottom - mMovingIconImageView.getHeight() * scaleForImageView);
mMovingIconImageView.setY(newMovingIconImageViewY);
final float newBottomSheetBackgroundImageContainerY = mOriginalBottomSheetBackgroundImageViewY * (1 - progress);
mBottomSheetTopHeader.setY(newBottomSheetBackgroundImageContainerY);
mBottomSheetTopHeader.getLayoutParams().height =
(int) getValFromProgress(mBottomSheetHeightPeeked - mMovingImageviewSize / 2, mBottomSheetHeightExpanded, progress);
((MarginLayoutParams) mBottomsheetContentView.getLayoutParams()).topMargin = (int) getValFromProgress(mBottomSheetHeightPeeked, mBottomSheetHeightExpanded, progress);
mBottomsheetContentView.requestLayout();
mBottomSheetTopHeader.requestLayout();
}
};
}
示例4: getViewTransformer
import com.flipboard.bottomsheet.ViewTransformer; //导入依赖的package包/类
/**
* Override this to proved a custom {@link ViewTransformer}.
*/
ViewTransformer getViewTransformer();