android - Linear layout children not scrolling -
i'm trying add image views linear layout @ runtime.
<linearlayout android:id="@+id/llfolderlayout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight=".65" android:orientation="horizontal" android:scrollbars="horizontal" > </linearlayout>
linearlayout llfoldertabs = (linearlayout) myfolder.findviewbyid(r.id.llfolderlayout); imageview imgtab = new imageview(activity); imgtab.setid(i); imgtab.settag(i); imgtab.setimagedrawable( mcontext.getresources().getdrawable(r.drawable.icon_folder_inactive)); if (i == 0) { imgtab.setimagedrawable( mcontext.getresources().getdrawable(r.drawable.icon_folder_active)); // imgtab.setpadding(10, 0, 4, 0); linearlayout.layoutparams lp = new linearlayout.layoutparams( 74, layoutparams.match_parent); lp.setmargins(15, 0, 0, 0); imgtab.setlayoutparams(lp); } else { // imgtab.setpadding(4, 0, 4, 0); linearlayout.layoutparams lp = new linearlayout.layoutparams( 74, layoutparams.match_parent); lp.setmargins(30, 0, 0, 0); imgtab.setlayoutparams(lp); } llfoldertabs.addview(imgtab);
however, when number of children exceeds screen size doesn't scroll horizontally - how can achieve effect?
scrollview
special kind of layout, designed hold view larger actual size. when views size goes beyond scrollview size, automatically adds scroll bars , can scrolled vertically.
<scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dp" android:fillviewport="false"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> </linearlayout> </scrollview>
http://javatechig.com/android/android-scrollview-example
http://www.androidhub4you.com/2012/09/horizontal-scroll-view-in-android.html
Comments
Post a Comment