void setThumbviewImages(int position)
{
//set margin between two images.
LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 0, 5, 0);
//universal image loader
options1 = new DisplayImageOptions.Builder()
.bitmapConfig(Bitmap.Config.ARGB_8888)
.cacheInMemory()
.cacheOnDisc()
.resetViewBeforeLoading()
.build();
int n = arrl_product.size();
for (int i = 0; i < n; i++)
{
// Item item = arrItem.get(i);
Product p = arrl_product.get(i);
//custom layout for each imageview. which i required
final View view_lyt = lyt_Inflater.inflate(R.layout.lyt_com_thumb_img, null);
final ImageView imageView = (ImageView) view_lyt.findViewById(R.id.non_com_grid_img);
imageView.setLayoutParams(new RelativeLayout.LayoutParams(img_width, img_height));
animateFirstListener1 = new Constant.AnimateFirstDisplayListener(new ProgressBar(Act_Comm.this));
final String image_url = p.arr_images.get(0).image_method;
imageView.setTag(i);
imageLoader1.displayImage(image_url, imageView, options1, animateFirstListener1);
imageView.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
}
});
lin_thumb.addView(view_lyt, params);
}
}
我的XML文件
<HorizontalScrollView
android:id="@+id/com_iview_horizontalScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:visibility="visible" >
<LinearLayout
android:id="@+id/com_iview_lin_imageview"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
二lyt_com_thumb_img.xml佈局
<
?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/thumb_main_Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="3dp" >
<ImageView
android:id="@+id/non_com_grid_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:src="@drawable/icon" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone" />
</RelativeLayout>
添加LinaerLayout在水平方向和一個圖像添加一個到它,並在年底這個LinearLayout中添加水平滾動型 –
這裏是另外@ MD – Banku