I have a layout like this:
<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" />
And code like this :
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);
}
When the btnFr gets pushed, btnFr and BtnNl have to move to the middle (where the noLanguageBtn is).
Everything works fine the only problem is that when BtnFr gets pushed, it has to move on top of BtnNl. When BtnNl gets pushed, it has to move on top of BtnFr. How can i do this? at the moment btnFr always goes on top of BtnNl because it's defined later in the layout...
Use this at the end of the animation BtnNl.bringToFront()
EDIT Try this: In the first portion of code when BTN1 click, instead of
btnNl.StartAnimation (anim1);
btnFr.StartAnimation (anim2);
flip the order like this
btnFr.StartAnimation (anim2);
btnNl.StartAnimation (anim1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.