I am trying to add images to scrollview dynamically. To add images to scrollview I am using this code:
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>
So I need to add images to this scrollview like this:
|-------------
|
|Image 1
|-------------
|
|Image 2
|-------------
|
|Image 3
|-------------
For this I need to change somehow content size of Scrollview ?
How this is done in Android ?
Thanks.
1 Answer