我正试图动态地将图像添加到滚动视图。要添加图像,滚动型我使用这个代码:如何动态添加图像到ScrollView?
LinearLayout sv = (LinearLayout)findViewById(R.id.filesScrollerLayout);
ImageView iv = new ImageView(this);
iv.setImageDrawable(new BitmapDrawable(pub.FirstPicture)); // same happens with ScaleDrawable.
iv.setScaleType(ScaleType.CENTER_INSIDE);
sv.addView(iv);
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/scrollView1"
android:background="#FFFF00" >
<LinearLayout
android:id="@+id/filesScrollerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
</ScrollView>
所以我需要将图片添加到这个滚动型是这样的:
|-------------
|
|Image 1
|-------------
|
|Image 2
|-------------
|
|Image 3
|-------------
为此,我需要改变滚动型莫名其妙内容的大小?
这是如何在Android中完成的?
谢谢。
使用一个ListView。那是他们的。 – njzk2 2012-04-25 13:44:34
也可以为ScrollView使用修正大小。 match_parent,最有可能的,而不是wrap_content,因为它可能只是长出屏幕 – njzk2 2012-04-25 13:45:33
我不想使用listView我想使用ScrollView与图像背景的按钮。 感谢提示 – Streetboy 2012-04-25 13:48:54