安卓的Horizo​​ntalScrollView中的巨大差距 [英] Big gaps in android's HorizontalScrollView

查看:105
本文介绍了安卓的Horizo​​ntalScrollView中的巨大差距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Horizo​​ntalScrollView和一个线性布局

I have an HorizontalScrollView and a Linear layout

   <HorizontalScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/filesScrollerLayout"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </LinearLayout>
</HorizontalScrollView>

我以编程方式尝试通过以下方式在linearLayout中添加视图:

Programmaticaly I'm trying to add views in the linearLayout with the following way:

     LinearLayout layout = (LinearLayout)findViewById(R.id.filesScrollerLayout);

     ImageView imageView1 = new ImageView(this);
     ImageView imageView2 = new ImageView(this);
     ImageView imageView3 = new ImageView(this);
     imageView1.setImageDrawable(Drawables);
     imageView2.setImageDrawable(Drawables);
     imageView3.setImageDrawable(Drawables);

问题在于,在水平滚动视图中,图像之间存在很大的间隙.我只希望图像彼此相邻.我该如何成功?

The problem is that in the horizontalscroll view there are big gaps between the images. I just want the images to be next to each other. How can I succeed that?

推荐答案

如果内容为ImageViews,则进行以下设置:

If the contents are ImageViews, set this:

android:adjustViewBounds="true"

这篇关于安卓的Horizo​​ntalScrollView中的巨大差距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆