xml - Android - ScrollView doesnt work on Relative Layout -
i put scrollview around relative layout adding dynamically. if set height of relative layout fixed amount goes off of page scrollview work.
example:
<scrollview android:id="@+id/scrollview1" android:layout_width="match_parent" android:layout_height="match_parent" android:fillviewport="true" > <relativelayout android:id="@+id/llcustomrow" android:layout_width="match_parent" android:layout_height="800dp" > </relativelayout> </scrollview>
but need relativelayout able hold many items add dynamically o set relativelayout height wrap_content. once add enough items relative layout going off screen scrollview doesnt register
below how dynamically adding relative layout
linearlayout mlinearlayout; relativelayout rlcopy; relativelayout[] rarray = new relativelayout[20]; int counter = 0; relativelayout llcustomrow; relativelayout.layoutparams paramsleft; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { mlinearlayout = (linearlayout) inflater.inflate( r.layout.customworkout, container, false); paramsleft = new relativelayout.layoutparams(relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content); llcustomrow = (relativelayout)mlinearlayout.findviewbyid(r.id.llcustomrow); for(int = 0;i<=rarray.length-1;i++){ rarray[i] = (relativelayout)view.inflate(getactivity(), r.layout.addworkoutlayout, null); paramsleft.addrule(relativelayout.align_parent_left); paramsleft.setmargins(10, 0, 0, 0); rarray[i].setlayoutparams(paramsleft); } button badd = (button) mlinearlayout.findviewbyid(r.id.baddexcercise); badd.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { rarray[counter].sety(rarray[counter-1].gety() + (rarray[counter-1].getheight() +25)); llcustomrow.addview(rarray[counter]); counter++; } }); return mlinearlayout; }
thanks
why using relativelayout? i'd advise switching linearlayout.
Comments
Post a Comment