首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >带左右空格的Android ImageView

带左右空格的Android ImageView
EN

Stack Overflow用户
提问于 2018-06-16 04:32:32
回答 2查看 154关注 0票数 1

我有一台带RelativeLayoutImageViewHorizontalScrollView。我的目标是让ImageView以全高但溢出宽度显示我的图像,以便您可以水平滚动图像。

下面是我的xml:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragment_indoor_tour"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="#ff0000">

        <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/scene"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:background="#ffff00" />
    </RelativeLayout>
</HorizontalScrollView>

它通常可以工作,但添加了一些左右间距,这是ImageView的一部分。

请参见屏幕截图。

间隔是从哪里来的?如何删除这种间距?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-06-16 04:58:22

下面的代码在我的例子中工作得很好。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragment_indoor_tour"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ff0000">

        <ImageView
            android:id="@+id/scene"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:background="#ffff00" />
    </RelativeLayout>
</HorizontalScrollView>

我认为图像本身有一个左右填充。除此之外,它应该工作得很好。

票数 0
EN

Stack Overflow用户

发布于 2018-06-16 04:42:12

尝试在imageView上添加此属性:

代码语言:javascript
复制
android:scaleType="fitXY"

代码语言:javascript
复制
android:layout_width="match_parent"

相对于相对布局和ImageView

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50882318

复制
相关文章

相似问题

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