android - horizontalScroll view doesnt scroll -
i have made horizontal view , within 1 linearlayout. xml file..
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/bg" > <imageview android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/img_view" /> <horizontalscrollview android:id="@+id/horizontalscrollview1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginleft="5dip" android:layout_marginright="5dip" android:scrollbars="horizontal"> </horizontalscrollview> <linearlayout android:id="@+id/linearlayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > </linearlayout> </linearlayout>
i want create 20 buttons should scroll horizontally in horizontalscroll view activity shows 4 buttons , doesnt scroll.
my code is
public class numericpage extends activity{ private linearlayout linear_layout; private horizontalscrollview hzv; button[] btn = new button[10]; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.numericpage); hzv = (horizontalscrollview) findviewbyid(r.id.horizontalscrollview1); linear_layout = (linearlayout) findviewbyid(r.id.linearlayout1); (int j = 0; j < 10; j++) { btn[j] = new button(this); btn[j].settext("" + j ); btn[j].setid(j); btn[j].setwidth(100); btn[j].setheight(40); linear_layout.addview(btn[j]); } } }
beginnr @ android.. plz help!! thnx
your linearlayout created outside horizontalscrollview, right layout this
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/bg" > <imageview android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/img_view" /> <horizontalscrollview android:id="@+id/horizontalscrollview1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginleft="5dip" android:layout_marginright="5dip" android:scrollbars="horizontal"> <linearlayout android:id="@+id/linearlayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" /> </horizontalscrollview> </linearlayout>
android horizontalscrollview
No comments:
Post a Comment