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.