1

我有两个相关的问题。

我在 editText 上应用幻灯片翻译,它是按钮。出于显而易见的原因,我创建了两个按钮,一个可见的,一个不可见的。为了隐藏可见的并显示不可见的,我正在使用以下代码:

public void onAnimationEnd(Animation animation) {
    textBox.setVisibility(View.GONE);
    button.setVisibility(View.GONE);
    button2.setVisibility(View.VISIBLE);
    textBox2.setVisibility(View.VISIBLE);
    textBox2.requestFocus();
    button2.setEnabled(true);
    button.setEnabled(false);
}

textBox原始的 editText在哪里,button是它的随附按钮。textBox2是我要展示的。

然而,原始的 editText 及其按钮仍然可见,而另一组没有出现。任何想法上面有什么问题?

其次,我可以在我的 .java 文件中找到屏幕大小,但是我如何将它传递到我的 .xml 动画文件中呢?或者有没有更好的方法来根据屏幕尺寸调整过渡量?

这是我调用动画的方式:

Animation translateAnimation = AnimationUtils.loadAnimation(first.this, R.anim.translate);
textBox.startAnimation(translateAnimation);

翻译.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" android:fromYDelta="0" android:toYDelta="-160" android:duration="50" />
4

1 回答 1

1

To answer the first part of your question you would probably want to call invalidate() on the views for which you have changed the visibility. For the second part it might be better if you could show how are you adjusting the transition in your code currently.

于 2012-08-29T08:59:55.187 回答