当前位置: 首页>>代码示例>>Java>>正文


Java InertialImitator类代码示例

本文整理汇总了Java中com.tumblr.backboard.imitator.InertialImitator的典型用法代码示例。如果您正苦于以下问题:Java InertialImitator类的具体用法?Java InertialImitator怎么用?Java InertialImitator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InertialImitator类属于com.tumblr.backboard.imitator包,在下文中一共展示了InertialImitator类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import com.tumblr.backboard.imitator.InertialImitator; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

	final View rootView = inflater.inflate(R.layout.fragment_constrain, container, false);

	final View constraintView = rootView.findViewById(R.id.constraint);

	final View circle = rootView.findViewById(R.id.circle);

	final InertialImitator motionImitatorX =
			new InertialImitator(MotionProperty.X, Imitator.TRACK_DELTA,
					Imitator.FOLLOW_SPRING, 0, 0);

	final InertialImitator motionImitatorY =
			new InertialImitator(MotionProperty.Y, Imitator.TRACK_DELTA,
					Imitator.FOLLOW_SPRING, 0, 0);

	new Actor.Builder(SpringSystem.create(), circle)
			.addMotion(motionImitatorX, View.TRANSLATION_X)
			.addMotion(motionImitatorY, View.TRANSLATION_Y)
			.build();

	rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
		@Override
		public void onGlobalLayout() {
			motionImitatorX.setMinValue(
					-constraintView.getMeasuredWidth() / 2 + circle.getMeasuredWidth() / 2);
			motionImitatorX.setMaxValue(
					constraintView.getMeasuredWidth() / 2 - circle.getMeasuredWidth() / 2);
			motionImitatorY.setMinValue(
					-constraintView.getMeasuredHeight() / 2 + circle.getMeasuredWidth() / 2);
			motionImitatorY.setMaxValue(
					constraintView.getMeasuredHeight() / 2 - circle.getMeasuredWidth() / 2);
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
				rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
			} else {
				rootView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
			}
		}
	});

	return rootView;
}
 
开发者ID:tumblr,项目名称:Backboard,代码行数:45,代码来源:ConstrainedFragment.java


注:本文中的com.tumblr.backboard.imitator.InertialImitator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。