Android ImageView宽度与父级不匹配
我拥有的内容:Android ImageView宽度与父级不匹配,android,android-layout,imageview,Android,Android Layout,Imageview,我拥有的内容:滚动视图,在它里面 LinearLayout (orientation=“vertical”, 布局\u width=“匹配父项”, layout_height=“wrap_content”) 里面 ImageView (layout\u width=“匹配父项”, 布局高度=“包装内容”)和 TextView 我想要的:ImageView应该保持纵横比和数学父宽度,以及ImageView下面的文本 我使用了ImageView参数的不同组合:adjustViewBounds tru
滚动视图
,在它里面
LinearLayout
(orientation=“vertical”,
布局\u width=“匹配父项”,
layout_height=“wrap_content”
)
里面
ImageView
(layout\u width=“匹配父项”,
布局高度=“包装内容”
)和
TextView
我想要的:ImageView
应该保持纵横比和数学父宽度,以及ImageView
下面的文本
我使用了ImageView参数的不同组合
:adjustViewBounds true/false
和所有scaleType
,但我无法得到我想要的:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="100dp"
android:id="@+id/iv"
android:background="#f0f"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Always work!!"
android:gravity="center"
android:textSize="26sp"
/>
</LinearLayout>
</ScrollView>
注意:如果scaleType
没有帮助,请尝试使用android:background=“”
代替android:src=“”
您是否可以发布您的布局xml,或者发布一个屏幕,显示您得到的内容及其外观?阅读代码比通过描述获取代码要容易得多……如果图像比父图像小,该怎么办?是否应该扩大规模?这将扭曲图像。请尝试使用ImageView的
scaleType=“fitCenter”