I have a scrollview in which i have multiple images being added dyanimcally through code. I just want to show one image per page.Image should be full screen image.How can i make it through code.Help me please if anyone knows the answer.here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/sv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:id="@+id/innerL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
I am adding images in innerL(linearlayout).Images are adding perfectly but it is by default wrap content somehow.Here is my code which is adding images in innerL:
LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.innerL);
byte[] img = pt.getImage(imgurl);
if(img != null)
{
Bitmap bitmap=BitmapFactory.decodeByteArray(img,0,img.length);
ImageView newImg = new ImageView(con);
ll.addView(newImg);
newImg.setImageBitmap(bitmap);
}
Set this property to your parent ScrollView
<ScrollView android:fillViewport="true"
Then if you want your inner image fill whole scrollview then set width and height of imageview to fillparent.
It work Perfectly 100%.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With