[英]images are too far into LinearLayout and HorizontalScrollView
how can i set the ranges of Images which are in the HorizontalScrollView 如何设置HorizontalScrollView中图像的范围
As you can see the images are not so close between themselves, i need them to be close. 如您所见,图像之间的距离不是很近,我需要它们很近。
This is my code for the HorizontalScrollView xml file: 这是我的HorizontalScrollView xml文件的代码:
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="5dp"
android:id="@+id/hscrollview"
android:layout_weight="0.2">
<LinearLayout
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" />
This is what i have tried programmatically. 这就是我以编程方式尝试过的方法。
private ImageView getImageView(final Integer image, final int index) {
imageView = new ImageView(getApplicationContext());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 0, 0, 0);
imageView.setLayoutParams(lp);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
viewPager.setCurrentItem(index);
}
});
imageView.setImageResource(image);
return imageView;
}
Try Changing the xml to 尝试将xml更改为
<HorizontalScrollView
android:layout_width="fill_parent"
android:background="@drawable/itemlistbg"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/itemlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"/>
</HorizontalScrollView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.