我有这样的布局:
<LinearLayout
android:id="@+id/buttonLayout"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/btnNl"
android:layout_width="65dp"
android:layout_height="65dp"
android:background="@drawable/splashBtnOrange"
android:layout_marginRight="5.50dp" />
<Button
android:id="@+id/btnNoLanguage"
android:layout_width="65dp"
android:layout_height="65dp"
android:background="@drawable/splashBtnWhite"
android:layout_marginRight="5.50dp" />
<Button
android:id="@+id/btnFr"
android:layout_width="65dp"
android:layout_height="65dp"
android:background="@drawable/splashBtnGreen" />
这样的代码:
void HandleBtnNlClick (object sender, EventArgs e)
{
controller.SaveSetting("language","nl");
TranslateAnimation anim2 = new TranslateAnimation(0,-((int)(btnFr.GetX() - btnNoLanguage.GetX())), 0, 0);
anim2.Duration = 1000;
anim2.FillAfter = true;
TranslateAnimation anim1 = new TranslateAnimation(0, btnNoLanguage.GetX()-btnNl.GetX(), 0, 0);
anim1.Duration = 1000;
anim1.FillAfter = true;
btnNl.StartAnimation (anim1);
btnFr.StartAnimation (anim2);
//_initModel.gotoNextScreen ();
}
void HandleBtnFrClick (object sender, EventArgs e)
{
controller.SaveSetting("language","fr");
TranslateAnimation anim1 = new TranslateAnimation(0, btnNoLanguage.GetX()-btnNl.GetX(), 0, 0);
anim1.Duration = 1000;
anim1.FillAfter = true;
TranslateAnimation anim2 = new TranslateAnimation(0,-((int)(btnFr.GetX() - btnNoLanguage.GetX())), 0, 0);
anim2.Duration = 1000;
anim2.FillAfter = true;
btnNl.StartAnimation (anim1);
btnFr.StartAnimation (anim2);
}
当推动btnFr时,btnFr和BtnNl必须移动到中间 (noLanguageBtn所在的地方)。
一切正常,唯一的问题是当BtnFr被推动时, 它必须在BtnNl之上移动。当BtnNl被推动时,它必须移动到BtnFr之上。我怎样才能做到这一点?目前btnFr总是在BtnNl之上 因为它在布局后面定义...
答案 0 :(得分:0)
在动画结束时使用此功能 BtnNl.bringToFront()
EDIT 试试这个: 在BTN1点击的第一部分代码中,而不是
btnNl.StartAnimation (anim1);
btnFr.StartAnimation (anim2);
像这样翻转订单
btnFr.StartAnimation (anim2);
btnNl.StartAnimation (anim1);