Android animation Fragment sliding in with time delay -
i split screen 2 per design , top part filled top fragment , bottom bottom fragment. initial alignment works fine.
but have series of top fragments have slide right left time delay of 0.5 sec each. also, when first fragment slides in before finishes sliding left (probably when 25% left complete left slide) second slide has start right.
all these need happen immediately.
so, wrote below code, last fragment slides in, rest of fragments not. please let me know how correct code.
my activity class
import android.app.activity; import android.app.fragment; import android.app.fragmentmanager; import android.app.fragmenttransaction; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; public class sampleactivity extends activity { private void incarnate(fragmentmanager fm){ int layoutid = r.id.frame; boolean fragmentwasnull = false; fragment f = fm.findfragmentbyid(layoutid); fragmenttransaction ft = fm.begintransaction(); ft.add(layoutid, new clinicloudgreyfragment(), "main").commit(); fragmenttransaction ft1 = fm.begintransaction(); ft1.add(r.id.bottompanel,new clinicloudbottonfragment()); ft1.commit(); } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_sample); fragmentmanager fm = getfragmentmanager(); incarnate(fm); fragmenttransaction transaction = fm.begintransaction(); transaction.setcustomanimations(r.anim.slidein, r.anim.slideout); transaction.replace(r.id.frame, new clinicloudgreyfragment()).commit(); fragmenttransaction transaction1 = fm.begintransaction(); transaction1.setcustomanimations(r.anim.slideinwithhalfasecdelay, r.anim.slideout); transaction1.replace(r.id.frame, new clinicloudpurplefragment()).commit(); fragmenttransaction transaction2 = fm.begintransaction(); transaction2.setcustomanimations(r.anim.slideinwithasecdelay, r.anim.slideout); transaction2.replace(r.id.frame, new clinicloudorangefragment()).commit(); fragmenttransaction transaction3 = fm.begintransaction(); transaction3.setcustomanimations(r.anim.slideinwithoneandhalfasecdelay, r.anim.slideout); transaction3.replace(r.id.frame, new clinicloudyellowfragment()).commit(); fragmenttransaction transaction4 = fm.begintransaction(); transaction4.setcustomanimations(r.anim.slideinwithtwosecdelay, r.anim.slideout); transaction4.replace(r.id.frame, new clinicloudbluefragment()).commit(); } } sliding in , sliding out (i dont want sliding out sliding in left right) sliding in ========== <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <objectanimator android:valuefrom="1" android:valueto="0" android:valuetype="floattype" android:propertyname="xfraction" android:startoffset="1000" /> <objectanimator android:valuefrom="1.0" android:valueto="0.0" android:valuetype="floattype" android:propertyname="alpha" android:duration="@android:integer/config_mediumanimtime" /> </set> sliding out =========== <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <objectanimator android:valuefrom="0" android:valueto="0" android:valuetype="floattype" android:propertyname="translationx" android:duration="@android:integer/config_mediumanimtime" /> <objectanimator android:valuefrom="0.0" android:valueto="0.0" android:valuetype="floattype" android:propertyname="alpha" android:duration="@android:integer/config_mediumanimtime" /> </set> fragment example: ----------------- <?xml version="1.0" encoding="utf-8"?> <com.clinicloud.app.ll xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#1893d2" > </com.clinicloud.app.ll> public class ll extends linearlayout { public ll(context context) { super(context); } public ll(context context, attributeset attrs) { super(context, attrs); } public float getxfraction() { final int width = getwidth(); if (width != 0) return getx() / getwidth(); else return getx(); } public void setxfraction(float xfraction) { final int width = getwidth(); float newwidth = (width > 0) ? (xfraction * width) : -9999; setx(newwidth); } }
i followed last answer thread can't objectanimator working xfraction
Comments
Post a Comment