首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使两个图像视图的大小能够覆盖水平滚动视图中的线性布局中的屏幕

如何使两个图像视图的大小能够覆盖水平滚动视图中的线性布局中的屏幕
EN

Stack Overflow用户
提问于 2013-08-15 09:06:19
回答 3查看 1K关注 0票数 3

我试图在水平滚动视图内的线性布局中获得2个(或更多)图像视图,这样每个图像都被缩放以适应屏幕高度,而不会扭曲图像(即屏幕上显示尽可能大的一个图像),滚动以查看下一个图像。

一旦第二个图像被添加,我得到两个小图像在彼此旁边(尺寸为217 *300 to对于这两个图像)。目前,我的activity_main.xml看起来如下..

代码语言:javascript
运行
复制
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
        >

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            >
            <ImageView
                android:id="@+id/image1"
                android:src="@drawable/luke"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitCenter"
                />
            <ImageView
                android:id="@+id/image2"
                android:src="@drawable/luke"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitCenter"
                />


        </LinearLayout>
    </HorizontalScrollView>


</FrameLayout>

我在布局上尝试了match_parent、fill_parent、wrap_content的各种组合,在图像视图上尝试了所有的scaleTypes,并花了一天的时间浏览网络,寻找一个与我想要的相似的示例,但没有运气。

EN

Stack Overflow用户

回答已采纳

发布于 2013-08-15 09:15:25

我要说的是这两件事:

代码语言:javascript
运行
复制
     <ImageView
          android:layout_height = "match_parent"
          android:layout_width = "10dp" />

这是棘手的部分。在运行时获取屏幕宽度,并将其设置为imageView。

票数 3
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18249520

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档