Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在相对布局内的scrollview中维护android中的图像纵横比?_Android_Image_Aspect Ratio - Fatal编程技术网

如何在相对布局内的scrollview中维护android中的图像纵横比?

如何在相对布局内的scrollview中维护android中的图像纵横比?,android,image,aspect-ratio,Android,Image,Aspect Ratio,我在横幅(高度48dp)和页脚(高度48dp)之间创建了一个可滚动图像的RelativeLayout。在分辨率为320 X 480的手机布局上加载尺寸为767 X 1105的图像时,图像宽度适合设备宽度,但图像的高度被拉伸,这会干扰纵横比。请提出解决方案 以下是布局xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/ap

我在横幅(高度48dp)和页脚(高度48dp)之间创建了一个可滚动图像的RelativeLayout。在分辨率为320 X 480的手机布局上加载尺寸为767 X 1105的图像时,图像宽度适合设备宽度,但图像的高度被拉伸,这会干扰纵横比。请提出解决方案

以下是布局xml:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/p_1_prastavana_1"
    android:orientation="vertical" >

    <include
        android:id="@+id/banner1"
        android:layout_alignParentTop="true"
        layout="@layout/topheadings" />

    <LinearLayout
        android:id="@+id/footer1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical" >

        <include layout="@layout/footer" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/footer1"
        android:layout_below="@id/banner1" >

        <ScrollView
            android:id="@+id/scroll1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:fillViewport="false"
            android:orientation="vertical" >

            <ImageSwitcher
                android:id="@+id/content_image"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:scaleType="centerCrop"
                android:src="@drawable/p_1_prastavana_1" >
            </ImageSwitcher>
        </ScrollView>
    </LinearLayout>

</RelativeLayout>


我不知道这是否是问题的原因,但ScrollView通常应设置为沿其方向“包装内容”。也不需要将其置于线性布局中。您正在从服务器或SDCard下载图像。我不知道这是否是问题的原因,但ScrollView通常应设置为沿其方向“包装内容”。也不需要将其放在线性布局中。您正在从服务器或SD卡下载图像