Skip to content Skip to sidebar Skip to footer

Android How To Add A Custom Horizontal Scrollview To List Of Images

I am going to developing an application where my 1st page is a list of images. I want it should be better visible. in a horizontal srcollview manner having some good visibility. Ho

Solution 1:

Take a look at the Gallery widget.

Solution 2:

you can use this,

in XML use horizontalscrollView

<HorizontalScrollView 
android:layout_width="match_parent"android:layout_height="100dp"android:layout_marginTop="10dp"android:layout_marginBottom="10dp"android:paddingLeft="15dp"android:paddingRight="15dp"android:id="@+id/hrscroll">
<LinearLayout 
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:id="@+id/scrollview_layout">

</LinearLayout>

</HorizontalScrollView>

java code..

LayoutParamsparams=newLayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
        params.width=110;
        LayoutParamsparams2=newLayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
        params2.width=100;
        LinearLayoutgall= (LinearLayout) findViewById(R.id.scrollview_layout);
        for(int i=0;i<=5;i++){
        LinearLayoutLimages=newLinearLayout(this);
        Limages.setOrientation(LinearLayout.VERTICAL);
        ImageViewimages=newImageView(this);
      //  images.setScaleType(ImageView.ScaleType.FIT_CENTER);
        images.setLayoutParams(params2);
        images.setBackgroundResource(R.drawable.imagez);
        Limages.addView(images);
        Limages.setLayoutParams(params);
        gall.addView(Limages);
         }

Post a Comment for "Android How To Add A Custom Horizontal Scrollview To List Of Images"