android - Some layouts expanding slower than others when using LayoutTransition.CHANGING -
i have 19 horizontal linearlayouts arranged vertically within linearlayout. empty , onclick show text. animating layouts with
parentone.getlayouttransition().enabletransitiontype(layouttransition.changing);
for reason first 7 layouts seem opening onclick little slower 8th. split second have asked others @ when open make sure i'm not crazy. post entire file huge , on maximum allowable text on this. here meat , potatoes. so, why layouts opening slower others? numbers 8-19 open instantly onclick , 1-7 have small delay noticeable.
java on create
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getsupportactionbar().hide(); setcontentview(r.layout.tacticalfieldcarestudy); linearlayout parentone = (linearlayout) findviewbyid(r.id.tfclayoutone); linearlayout parenttwo = (linearlayout) findviewbyid(r.id.tfclayouttwo); linearlayout parenttwobullets = (linearlayout)findviewbyid(r.id.tfclayouttwobullets); linearlayout parentthree = (linearlayout)findviewbyid(r.id.tfclayoutthree); linearlayout parentthreebullets = (linearlayout)findviewbyid(r.id.tfclayoutthreebullets); linearlayout parentfour = (linearlayout)findviewbyid(r.id.tfclayoutfour); linearlayout parentfourbullets = (linearlayout)findviewbyid(r.id.tfclayoutfourbullets); linearlayout parentfive = (linearlayout)findviewbyid(r.id.tfclayoutfive); linearlayout parentfivebullets = (linearlayout)findviewbyid(r.id.tfclayoutfivebullets); linearlayout parentsix = (linearlayout)findviewbyid(r.id.tfclayoutsix); linearlayout parentsixbullets = (linearlayout)findviewbyid(r.id.tfclayoutsixbullets); linearlayout parentseven = (linearlayout)findviewbyid(r.id.tfclayoutseven); linearlayout parentsevenbullets = (linearlayout)findviewbyid(r.id.tfclayoutsevenbullets); linearlayout parenteight = (linearlayout)findviewbyid(r.id.tfclayouteight); linearlayout parenteightbullets = (linearlayout)findviewbyid(r.id.tfclayouteightbullets); linearlayout parentnine = (linearlayout)findviewbyid(r.id.tfclayoutnine); linearlayout parentninebullets = (linearlayout)findviewbyid(r.id.tfclayoutninebullets); linearlayout parentten = (linearlayout)findviewbyid(r.id.tfclayoutten); linearlayout parenttenbullets = (linearlayout)findviewbyid(r.id.tfclayouttenbullets); linearlayout parenteleven = (linearlayout)findviewbyid(r.id.tfclayouteleven); linearlayout parenttwelve = (linearlayout)findviewbyid(r.id.tfclayouttwelve); linearlayout parentthirteen = (linearlayout)findviewbyid(r.id.tfclayoutthirteen); linearlayout parentthirteenbullets = (linearlayout)findviewbyid(r.id.tfclayoutthirteenbullets); linearlayout parentfourteen = (linearlayout)findviewbyid(r.id.tfclayoutfourteen); linearlayout parentfifteen = (linearlayout)findviewbyid(r.id.tfclayoutfifteen); linearlayout parentfifteenbullets = (linearlayout)findviewbyid(r.id.tfclayoutfifteenbullets); linearlayout parentsixteen = (linearlayout)findviewbyid(r.id.tfclayoutsixteen); linearlayout parentsixteenbullets = (linearlayout)findviewbyid(r.id.tfclayoutsixteenbullets); linearlayout parentseventeen = (linearlayout)findviewbyid(r.id.tfclayoutseventeen); linearlayout parentseventeenbullets = (linearlayout)findviewbyid(r.id.tfclayoutseventeenbullets); linearlayout parenteighteen = (linearlayout)findviewbyid(r.id.tfclayouteighteen); linearlayout parenteighteenbullets = (linearlayout)findviewbyid(r.id.tfclayouteighteenbullets); linearlayout parentnineteen = (linearlayout)findviewbyid(r.id.tfclayoutnineteen); linearlayout parentnineteenbullets = (linearlayout)findviewbyid(r.id.tfclayoutnineteenbullets); parentone.getlayouttransition().enabletransitiontype(layouttransition.changing); parenttwo.getlayouttransition().enabletransitiontype(layouttransition.changing); parenttwobullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentthree.getlayouttransition().enabletransitiontype(layouttransition.changing); parentthreebullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentfour.getlayouttransition().enabletransitiontype(layouttransition.changing); parentfourbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentfive.getlayouttransition().enabletransitiontype(layouttransition.changing); parentfivebullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentsix.getlayouttransition().enabletransitiontype(layouttransition.changing); parentsixbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentseven.getlayouttransition().enabletransitiontype(layouttransition.changing); parentsevenbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parenteight.getlayouttransition().enabletransitiontype(layouttransition.changing); parenteightbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentnine.getlayouttransition().enabletransitiontype(layouttransition.changing); parentninebullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentten.getlayouttransition().enabletransitiontype(layouttransition.changing); parenttenbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parenteleven.getlayouttransition().enabletransitiontype(layouttransition.changing); parenttwelve.getlayouttransition().enabletransitiontype(layouttransition.changing); parentthirteen.getlayouttransition().enabletransitiontype(layouttransition.changing); parentthirteenbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentfourteen.getlayouttransition().enabletransitiontype(layouttransition.changing); parentfifteen.getlayouttransition().enabletransitiontype(layouttransition.changing); parentfifteenbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentsixteen.getlayouttransition().enabletransitiontype(layouttransition.changing); parentsixteenbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentseventeen.getlayouttransition().enabletransitiontype(layouttransition.changing); parentseventeenbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parenteighteen.getlayouttransition().enabletransitiontype(layouttransition.changing); parenteighteenbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); parentnineteen.getlayouttransition().enabletransitiontype(layouttransition.changing); parentnineteenbullets.getlayouttransition().enabletransitiontype(layouttransition.changing); }
one of 7 java methods has unwanted delay onclick
private boolean mopenone = false; public void toggleone(view view){ textview stepone = (textview)findviewbyid(r.id.stepone); imageview toggle = (imageview)findviewbyid(r.id.togglestepone); if(mopenone){ stepone.settext("step 1:"); toggle.setimageresource(r.drawable.open); } else{ stepone.settext("1. casualties altered mental status should disarmed immediately."); toggle.setimageresource(r.drawable.close); } mopenone = !mopenone; }
xml unwanted delay onclick
<linearlayout android:id="@+id/tfclayoutone" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dp" android:animatelayoutchanges="true" android:onclick="toggleone" android:background="#606060" > <imageview android:id="@+id/togglestepone" android:src="@drawable/open" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="5dp" android:layout_gravity="center_vertical" /> <textview android:id="@+id/stepone" android:text="step 1:" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingleft="0dp" style="@style/bullet" /> </linearlayout>
java 8th method works without delay
private boolean mopeneight = false; public void toggleeight(view view){ textview stepeight = (textview)findviewbyid(r.id.stepeight); imageview toggle = (imageview)findviewbyid(r.id.togglestepeight); if(mopeneight){ stepeight.settext("step 8:"); textview stepeightbulletone = (textview)findviewbyid(r.id.stepeightbulletone); textview stepeightbullettwo = (textview)findviewbyid(r.id.stepeightbullettwo); textview stepeightbulletthree = (textview)findviewbyid(r.id.stepeightbulletthree); textview stepeightbulletfour = (textview)findviewbyid(r.id.stepeightbulletfour); textview stepeightbulletfive = (textview)findviewbyid(r.id.stepeightbulletfive); textview stepeightbulletsix = (textview)findviewbyid(r.id.stepeightbulletsix); stepeightbulletone.settext(""); stepeightbullettwo.settext(""); stepeightbulletthree.settext(""); stepeightbulletfour.settext(""); stepeightbulletfive.settext(""); stepeightbulletsix.settext(""); stepeightbulletone.getlayoutparams().height = 0; stepeightbullettwo.getlayoutparams().height = 0; stepeightbulletthree.getlayoutparams().height = 0; stepeightbulletfour.getlayoutparams().height = 0; stepeightbulletfive.getlayoutparams().height = 0; stepeightbulletsix.getlayoutparams().height = 0; toggle.setimageresource(r.drawable.open); } else{ stepeight.settext("8. prevention of hypothermia"); textview stepeightbulletone = (textview)findviewbyid(r.id.stepeightbulletone); textview stepeightbullettwo = (textview)findviewbyid(r.id.stepeightbullettwo); textview stepeightbulletthree = (textview)findviewbyid(r.id.stepeightbulletthree); textview stepeightbulletfour = (textview)findviewbyid(r.id.stepeightbulletfour); textview stepeightbulletfive = (textview)findviewbyid(r.id.stepeightbulletfive); textview stepeightbulletsix = (textview)findviewbyid(r.id.stepeightbulletsix); stepeightbulletone.settext("a. minimize casualty's exposure elements. keep protective gear on or casualty if feasible."); stepeightbullettwo.settext("b. replace wet clothing dry if possible. casualty onto insulated surface possible."); stepeightbulletthree.settext("c. apply ready-heat blanket hypothermia prevention , management kit (hpmk) casualty's torso (not directly on skin) , cover casualty heat-reflective shell (hrs)."); stepeightbulletfour.settext("d. if hrs not available, recommended combination of blizzard survival blanket , ready heat blanket may used."); stepeightbulletfive.settext("e. if items mentioned above not available, use dry blankets, poncho liners, sleeping bags, or retain heat , keep casualty dry."); stepeightbulletsix.settext("f. warm fluids preferred if iv fluids required."); stepeightbulletone.getlayoutparams().height = viewgroup.layoutparams.wrap_content; stepeightbullettwo.getlayoutparams().height = viewgroup.layoutparams.wrap_content; stepeightbulletthree.getlayoutparams().height = viewgroup.layoutparams.wrap_content; stepeightbulletfour.getlayoutparams().height = viewgroup.layoutparams.wrap_content; stepeightbulletfive.getlayoutparams().height = viewgroup.layoutparams.wrap_content; stepeightbulletsix.getlayoutparams().height = viewgroup.layoutparams.wrap_content; toggle.setimageresource(r.drawable.close); } mopeneight = !mopeneight; }
xml of 1 of layouts works without delay
<linearlayout android:id="@+id/tfclayouteightbullets" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="#a0a0a0" android:animatelayoutchanges="true" android:onclick="toggleeight" > <linearlayout android:id="@+id/tfclayouteight" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dp" android:animatelayoutchanges="true" android:background="#a0a0a0" > <imageview android:id="@+id/togglestepeight" android:src="@drawable/open" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="5dp" android:layout_gravity="center_vertical" /> <textview android:id="@+id/stepeight" android:text="step 8:" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingleft="0dp" style="@style/bullet" /> </linearlayout> <textview android:id="@+id/stepeightbulletone" android:layout_width="wrap_content" android:layout_height="0dp" style="@style/bulletindented" /> <textview android:id="@+id/stepeightbullettwo" android:layout_width="wrap_content" android:layout_height="0dp" style="@style/bulletindented" /> <textview android:id="@+id/stepeightbulletthree" android:layout_width="wrap_content" android:layout_height="0dp" style="@style/bulletindented" /> <textview android:id="@+id/stepeightbulletfour" android:layout_width="wrap_content" android:layout_height="0dp" style="@style/bulletindented" /> <textview android:id="@+id/stepeightbulletfive" android:layout_width="wrap_content" android:layout_height="0dp" style="@style/bulletindented" /> <textview android:id="@+id/stepeightbulletsix" android:layout_width="wrap_content" android:layout_height="0dp" style="@style/bulletindented" /> </linearlayout>
well figured out. looks though processing issue. if had guess each time called method search through giant list of linearlayouts in oncreate method animation open it.
in oncreate method define crap ton of linear layouts such
linearlayout parentone = (linearlayout) findviewbyid(r.id.tfclayoutone); parentone.getlayouttransition().enabletransitiontype(layouttransition.changing);
the fix:
i separated of them , placed them in respective onclick methods. now, when click them open faster other pages setup similarly, changing well. java methods were:
private boolean mopenone = false; public void toggleone(view view){ textview stepone = (textview)findviewbyid(r.id.stepone); imageview toggle = (imageview)findviewbyid(r.id.togglestepone); if(mopenone){ stepone.settext("step 1:"); toggle.setimageresource(r.drawable.open); } else{ stepone.settext("1. casualties altered mental status should disarmed immediately."); toggle.setimageresource(r.drawable.close); } mopenone = !mopenone;
}
i have changed them to:
private boolean mopenone = false; public void toggleone(view view){ textview stepone = (textview)findviewbyid(r.id.stepone); imageview toggle = (imageview)findviewbyid(r.id.togglestepone); linearlayout parentone = (linearlayout) findviewbyid(r.id.tfclayoutone); parentone.getlayouttransition().enabletransitiontype(layouttransition.changing); if(mopenone){ stepone.settext("step 1:"); toggle.setimageresource(r.drawable.open); } else{ stepone.settext("1. casualties altered mental status should disarmed immediately."); toggle.setimageresource(r.drawable.close); } mopenone = !mopenone; }
hope helps others!
Comments
Post a Comment