我正在尝试使用此库,我注意到您可以在 xml 中添加一个配置面板:
<com.facebook.rebound.ui.SpringConfiguratorView
android:id="@+id/spring_configurator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
/>
这会影响此代码:
SpringSystem springSystem = SpringSystem.create();
// Add a spring to the system.
Spring spring = springSystem.createSpring();
// Add a listener to observe the motion of the spring.
spring.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
// You can observe the updates in the spring
// state by asking its current value in onSpringUpdate.
float value = (float) spring.getCurrentValue();
float scale = 1f - (value * 0.5f);
myView.setScaleX(scale);
myView.setScaleY(scale);
}
});
我正在尝试做配置面板在没有它的情况下所做的同样的事情?有人知道该怎么做吗?这是我想做的一个例子 - 没有面板:http://facebook.github.io/rebound/
如果你问如何设置弹簧的张力和摩擦力,你必须使用SpringConfig
在您的情况下,您可以通过这样调用来设置单个弹簧的 SpringConfig:
SpringSystem springSystem = SpringSystem.create();
// Add a spring to the system.
Spring spring = springSystem.createSpring();
// Add a listener to observe the motion of the spring.
spring.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
// You can observe the updates in the spring
// state by asking its current value in onSpringUpdate.
float value = (float) spring.getCurrentValue();
float scale = 1f - (value * 0.5f);
myView.setScaleX(scale);
myView.setScaleY(scale);
}
});
// Specify your own TENSION or FRICTION value as an int
SpringConfig config = new SpringConfig(TENSION, FRICTION);
spring.setSpringConfig(config);