我有一个按钮,当它盘旋时会改变它的颜色,但我希望这个颜色过渡看起来很平滑。我怎样才能达到这个效果?
buttonLogin.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent e){
buttonLogin.setStyle("-fx-background-color: "
+ "rgba(1, 147, 255, 0.3);"
+ "\n-fx-border-color: "
+ "rgba(1, 147, 255, 0.5);");
}
});
buttonLogin.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent e){
buttonLogin.setStyle("-fx-background-color: "
+ "rgba(255, 255, 255, 0.5);"
+ "\n-fx-border-color: "
+ "rgba(255, 255, 255, 0.8);");
}
});
我尝试使用淡入淡出,动画,但我发现很难理解。有人可以解释一下吗?