Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.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
Android 设置ImageView';在滚动视图中,与设置的宽度和纵横比相对应的高度_Android_Android Layout_Android Studio - Fatal编程技术网

Android 设置ImageView';在滚动视图中,与设置的宽度和纵横比相对应的高度

Android 设置ImageView';在滚动视图中,与设置的宽度和纵横比相对应的高度,android,android-layout,android-studio,Android,Android Layout,Android Studio,我在下面有一个滚动视图,这样用户就可以滚动问题容器(图像视图+文本视图),如果问题文本非常大的话。问题是我希望ImageView根据其纵横比和宽度获取高度,并借助layout\u width设置为match\u parent属性 <ScrollView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:scroll

我在下面有一个
滚动视图
,这样用户就可以滚动问题容器(
图像视图
+
文本视图
),如果问题文本非常大的话。问题是我希望
ImageView
根据其纵横比和宽度获取高度,并借助
layout\u width
设置为
match\u parent
属性

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="none"
    android:layout_marginLeft="@dimen/activity_horizontal_margin"
    android:layout_marginRight="@dimen/activity_horizontal_margin" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="center_vertical" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:src="@drawable/set_1_question_2" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/activity_vertical_margin"
            android:textSize="18sp"
            android:text="@string/app_set_1_question_2_text" />

    </LinearLayout>

</ScrollView>
这对我的情况非常有效,感谢所有试图解决我问题的人。:)

android:adjustViewBounds    Set this to true if you want the ImageView to adjust its bounds to preserve the aspect ratio of its drawable.