2 つのリンクされた質問があります。
editText とそのボタンにスライドの翻訳を適用しています。明らかな理由から、1 つは表示され、もう 1 つは非表示の 2 つのボタンを作成しました。表示されていたものを非表示にし、表示されていなかったものを表示するために、次のコードを使用しています。
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);
Translate.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" />