安卓:滚动型延伸背景图片 [英] Android: Scrollview stretches background image

查看:120
本文介绍了安卓:滚动型延伸背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图让我的活动滚动,当我把我的RelativeLayout滚动视图中,发生这种情况:

So I am trying to make my activity scrollable, and when I put my relativelayout inside a scroll view, this happens:

这是code为上面的截图:

This is the code for the above screenshot:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/background"
        android:orientation="vertical"
        android:paddingLeft="60dp"
        android:paddingTop="53dp" >

        <ImageView
            android:id="@+id/gearImage"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_marginTop="70dp"
            android:clickable="true"
            android:contentDescription="@string/gearDescription_string"
            android:src="@drawable/gear" />
    </RelativeLayout>

</ScrollView>

如果我拿出滚动视图,原来的权利,但没有当然这是我想要的滚动功能:

If I take out the scrollview, it turns out right, but of course without the scrolling function which I want:

现在,有没有什么办法可以让它看起来像这样:

Now, is there any way I can get it to look like this:

所以,我仍然可以滚动,但如果他们到达的背景图像我的底部,它只是白色的(很难说,因为网页的背景是白色的,但我添加了一个白色矩形的底部第二图像显示我的意思)。不会有一个原因,他们反正到达底部。

So that I can still scroll, but if they reach the bottom of the background image I have, it's just white (hard to tell because the background of the webpage is white, but I added a white rectangle to the bottom of the second image to show what I mean). There wouldn't be a reason for them to reach the bottom anyways.

当然,如果您有任何其他建议,我怎么可以实现滚动视图不受背景图像拉伸,我是最高兴听到他们。

Of course, if you have any other suggestions as to how I can implement the scrollview without stretching by background image, I would be most delighted to hear about them.

感谢您。

推荐答案

它不工作的原因是,我的形象是在像素方面太大。我猜滚动视图被迫保持图像的原始大小,因此它的所作所为是正义的。它使长度的原始图像的全长,因为我的滚动视图是垂直的,压扁沿着宽度,因为我没有一个滚动视图会一边到另一边。

The reason it wasn't working was that my image was too large in terms of pixels. I guess the scrollview is compelled to keep the image at its original size, so what it did was just that. It made the length the full length of the raw image because my scrollview was vertical, and squished it along the width because I didn't have a scrollview going side to side.

简单的修正是使图像变小。真奇怪,它可以适当调整正常布局里面,但里面没有滚动视图。

The simple fix was to make the image smaller. How odd that it can resize properly inside a normal layout, but not inside scrollview.

这篇关于安卓:滚动型延伸背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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