こんにちは、Android の初心者です。私のプロジェクトでは、同じ位置に 2 つのレイアウトを表示する必要があり、ボタンが押されるたびに回転アニメーションを適用する必要があるという要件がありました。同じ位置に 2 つのレイアウトを作成して同じことを達成しました。 Layout.bringToFront() メソッドを使用してそれらを切り替えますが、場合によっては適切にアニメーション化される理由がわかりませんが、bringToFront() メソッドが私のレイアウトを前面に運びません
public void bodyClicked()
{
System.out.println("Inside Body Clicked...");
System.out.println("Enevelope boolean value... "+enevelopefocus);
System.out.println("Body Boolean Value..."+bodyfocus);
if(!bodyfocus)
{
bodyLayout.startAnimation(AnimationUtils.loadAnimation(AddJobNew.this, R.anim.rotate_right));
fromToRootLayout.startAnimation(AnimationUtils.loadAnimation(AddJobNew.this,R.anim.rotate_left));
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
fromToRootLayout.startAnimation(AnimationUtils.loadAnimation(AddJobNew.this, R.anim.rotate_center_after_left));
bodyLayout.startAnimation(AnimationUtils.loadAnimation(AddJobNew.this, R.anim.rotate_right_center));
bodyLayout.bringToFront();
bodyLayout.invalidate();
bodyLayout.requestFocus();
bodyfocus=true;
enevelopefocus=false;
System.out.println("Body CLicked Completed...");
System.out.println("Enevelope boolean value... "+enevelopefocus);
System.out.println("Body Boolean Value..."+bodyfocus);
fromToRootLayout.invalidate();
}
});
}
}, 500);
headerLayout.setVisibility(View.VISIBLE);
}
}
public void enevlopeCLicked()
{
System.out.println("Inside Enevelope Clicked...");
System.out.println("Enevelope boolean value... "+enevelopefocus);
System.out.println("Body Boolean Value..."+bodyfocus);
headerLayout1.setVisibility(View.GONE);
fromBodyLayout.setVisibility(View.GONE);
if(fromAddressTExtView.getText().toString().length()>0)
{
fromAddressTExtView.setVisibility(View.VISIBLE);
fromTopEditBtn.setVisibility(View.GONE);
fromcontactpick.setVisibility(View.GONE);
}
else
{
fromTopEditBtn.setVisibility(View.VISIBLE);
fromcontactpick.setVisibility(View.VISIBLE);
fromAddressTExtView.setVisibility(View.GONE);
}
if(toAddressTExtView.getText().toString().length()>0)
{
toAddressTExtView.setVisibility(View.VISIBLE);
toBottomEditBtn.setVisibility(View.GONE);
toContactPick.setVisibility(View.GONE);
}
else
{
toBottomEditBtn.setVisibility(View.VISIBLE);
toContactPick.setVisibility(View.VISIBLE);
toAddressTExtView.setVisibility(View.GONE);
}
if(!enevelopefocus)
{
fromToRootLayout.startAnimation(AnimationUtils.loadAnimation(AddJobNew.this, R.anim.rotate_left));
bodyLayout.startAnimation(AnimationUtils.loadAnimation(AddJobNew.this,R.anim.rotate_right));
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
bodyLayout.startAnimation(AnimationUtils.loadAnimation(AddJobNew.this, R.anim.rotate_right_center));
fromToRootLayout.startAnimation(AnimationUtils.loadAnimation(AddJobNew.this, R.anim.rotate_center_after_left));
fromToRootLayout.bringToFront();
fromToRootLayout.invalidate();
fromToRootLayout.requestFocus();
enevelopefocus=true;
bodyfocus=false;
System.out.println("Enevelope CLicked Completed...");
System.out.println("Enevelope boolean value... "+enevelopefocus);
System.out.println("Body Boolean Value..."+bodyfocus);
bodyLayout.invalidate();
}
});
}
}, 500);
headerLayout.setVisibility(View.VISIBLE);
}
}
ここでは、特定のボタンがクリックされるたびに body と enevelope の 2 つのフラグを使用しています助けて
ありがとう