Tag: 动画

Android:动画搜索视图

我正在尝试实现动画搜索视图(使用简单的扩展/折叠动画),但此论坛中的所有答案都无效。 我做了什么 @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); //Get the ID for the search bar LinearLayout int searchBarId = searchView.getContext().getResources().getIdentifier(“android:id/search_bar”, null, null); //Get the search bar Linearlayout LinearLayout searchBar = (LinearLayout) searchView.findViewById(searchBarId); //Give […]

是否可以在不使用EDT的情况下在Java Swing中执行活动渲染?

我正在研究使用缓冲策略和Javadoc上描述的以下技术: // Main loop while (!done) { // Prepare for rendering the next frame // … // Render single frame do { // The following loop ensures that the contents of the drawing buffer // are consistent in case the underlying surface was recreated do { // Get a new graphics context every time through […]

JavaFX:循环之间的旋转动画延迟

我使用以下代码基于RotatedTranstion为ImageView创建了一个动画: ImageView icon = ImageCache.getImage(“refresh.png”); RotateTransition rotateTransition = new RotateTransition(Duration.millis(2000), icon); rotateTransition.setByAngle(360.0); rotateTransition.setCycleCount(Timeline.INDEFINITE); rotateTransition.play(); 这导致以下动画: 行动中的轮换 你可能已经注意到动画gif,动画不连续,即动画周期之间有一个小的延迟(暂停)。 我试图看看API,但无法弄清楚导致这种延迟的原因以及我如何摆脱它。

延迟在java图形中不起作用

这是通过Bresenham算法在计算位置上绘制点的代码: public void drawBresenhamPoints(Graphics2D g2, List bresenham) throws InterruptedException { Graphics2D g = (Graphics2D) g2; if(bresenham == null) return; g.setColor(Color.DARK_GRAY); for(int i = 0; i < bresenham.size(); i = i+20) { int x = bresenham.get(i).x – pointWidth1/2; int y = bresenham.get(i).y – pointWidth1/2; int ovalW = pointWidth1; int ovalH = pointWidth1; g.fillOval(x, y, ovalW, ovalH); […]

JPanel中的多个动画(线程)

我正在尝试用Java编写棋盘游戏。 我有11个class,包括Main。 Board类扩展了JPanel并绘制了板图像以及骰子图像。 类Player,它扩展了JCoponent并实现了Runnable(Thread)。 每个玩家实例都是一个典当动画,它正在全面移动。 玩家类在棋盘上绘制棋子。 图案 代码如何: Board b=new Board(); Player p=new Player(); b.add(p); JPanel panel=new JPanel(); panel.add(b); add(panel); //adding the panel to the frame. 问题是我不能在棋盘上同时拥有多个棋子。 我已经尝试在另一个类中重新绘制所有玩家(作为非动画),但它不起作用。 我也试过JLayeredPane,但也许我做错了。 不幸的是,我无法改变上述模式,所以不要提出这个建议。 预先感谢您的帮助。 PS:我不能发布任何代码,因为它的巨大。 PPS:如果你问我,会给出更多的澄清。 编辑:我改革了我的问题。 是否可以在同一个面板上同时拥有两个动画? 如果答案是肯定的..我可以这样做吗?

如何让圆圈只显示动画一次

我有一个应用程序,显示多个圆圈,动画半径从0到300.我遇到的问题是它显示多个圆圈慢慢增加每个圆的半径。 我只想绘制一个增加半径的圆。 这是我的代码。 public class SplashLaunch extends View{ Handler cool = new Handler(); DrawingView v; Paint newPaint = new Paint(); int randomWidthOne = 0; int randomHeightOne = 0; private float radiusOne = 300; final int redColorOne = Color.RED; final int greenColorOne = Color.GREEN; private static int lastColorOne; ObjectAnimator radiusAnimator; private final Random theRandom = new […]

NineOldAndroids动画无法在API> 10上运行

我正在使用NineOldAndroid库来执行动画。 动画适用于API 10,应用程序强制关闭。 这是我的代码: import static com.nineoldandroids.view.ViewPropertyAnimator.animate; import android.content.Intent; import android.graphics.Canvas; import android.graphics.PixelFormat; import android.os.Build; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.WindowManager; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.view.MenuItem; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.nineoldandroids.animation.ObjectAnimator; public class ActivityActualMain extends SherlockActivity { LinearLayout container1, container2; RelativeLayout viewTree; ImageView […]

JavaFX – 如何获取Tab,Button等的背景颜色

问题描述:我无法在JavaFX中获得对象的背景。 我不是指Shapes,而是Buttons,Tabs等常规节点。 我不知道如何访问他们的背景颜色。 我想要的是? 我正在开发IDE,我想在选项卡上运行Color动画,其中包含用户想要打开的文件并且已存在于程序文件集合中。 在做这个动画之前,我想阅读原始标签背景颜色,并在动画结束时将颜色返回到标签。 此外,我想回到hover和selected属性,当我在动画中设置一些颜色并且它们永远不会回来时它会消失。 我在CSS文件中设置的所有颜色,我不想更改它。 我的问题:如何以编程方式获取和设置节点颜色? 或者如何使用保存原始属性进行颜色动画,并在动画结束时获取此属性? 一个简短的例子: sample.fxml styles.css的 .tab{ -fx-background-color: pink;} .tab:hover{ -fx-background-color: red;} .tab:selected{ -fx-background-color: yellow;}

Android动画的简单线程问题

我正在尝试使用一些简单的Android动画实现一个线程。 我只是在sleep()中遇到错误 – 它说我需要一个方法。 我知道可能有一个明显的解决方案。 我的应用程序只是放置一个随机位置移动的球。 我想要的是继续在随机位置放置形状。 无论如何,有人可以告诉我我的线程做错了吗? 谢谢。 public class DrawingTheBall extends View { Bitmap bball; Random randX, randY; double theta; Handler m_handler; Runnable m_handlerTask; //for some reason I get a syntax error here m_handler = new Handler(); public DrawingTheBall(Context context) { super(context); // TODO Auto-generated constructor stub bball = BitmapFactory.decodeResource(getResources(), R.drawable.blueball); //randX = […]

在JComboBox中使用动画GIF

我正在尝试在JComboBox中使用动画(GIF)图标。 由于DefaultListCellRenderer基于JLabel,因此在将它们放入ComboBoxModel时会直接支持ImageIcons。 但是,这不适用于动画GIF。 在下拉列表中,除非选中它们,否则它们根本不会显示(虽然GIF在常规JLabel中使用时可以正常工作) 填充combobox的代码很简单: ImageIcon[] data = new ImageIcon[4]; data[0] = new ImageIcon(“icon_one.gif”); data[1] = new ImageIcon(“icon_two.gif”); data[2] = new ImageIcon(“icon_three.gif”); data[3] = new ImageIcon(“icon_four.gif”); ComboBoxModel model = new DefaultComboBoxModel(data); setModel(model); icon_one.gif是静态的,显示没有任何问题。 其他的都是动画的。 (图像被正确加载,因为如果我将这些图标中的任何一个直接分配给JLabel,它们就显示得很好) 我还试图使用我自己的基于JPanel的ListCellRenderer(灵感来自这个问题的答案: Java动画GIF而不使用JLabel )。 这样做有点好但不理想。 只有在显示下拉列表时将鼠标移到它们上方才会显示图标。 所以我想这是一个修复问题,虽然我不知道在哪里 这是我的JPanel实现ListCellRenderer接口的部分。 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { […]