-1
我已經做了一個水平的視圖,並在裏面一個linearlayout。 XML文件..horizontalScroll view doesnt scroll
<?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>
我要創建20個按鍵應該在horizontalScroll視圖水平滾動,但我的活動只是顯示4個按鈕和滾動犯規。
我的代碼是
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);
for (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在機器人.. plz幫助! 日Thnx
三江源...愚蠢的錯誤:P – user3768423