Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show images in full screen in scrollview android

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);
            }
like image 549
Hamza Khalil Avatar asked Sep 18 '25 04:09

Hamza Khalil


1 Answers

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%.

like image 153
Macrosoft-Dev Avatar answered Sep 20 '25 17:09

Macrosoft-Dev