Android 我的图像不会根据父级大小拉伸
我希望我的图像大小正好是父元素的大小 我已经使用了这个“android:adjustViewBounds=“true”,但它不起作用。我试了很多次,但都失败了Android 我的图像不会根据父级大小拉伸,android,android-imageview,viewflipper,Android,Android Imageview,Viewflipper,我希望我的图像大小正好是父元素的大小 我已经使用了这个“android:adjustViewBounds=“true”,但它不起作用。我试了很多次,但都失败了 <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight=".6"> <ViewFlippe
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".6">
<ViewFlipper
android:id="@+id/viewflipper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoStart="true"
android:flipInterval="2000" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:src="@drawable/ic_launcher_background" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:src="@drawable/background" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/background" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/background" />
</ViewFlipper>
</RelativeLayout>
尝试将ImageView与scaleType和adjustViewBounds结合起来,如下所示:
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher_background" />
您可以使用fitXY | centerCrop | fitCenter和其他工具
请参见此处的scaleType的更多选项:
尝试将ImageView与scaleType和adjustViewBounds结合起来,如下所示:
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher_background" />
您可以使用fitXY | centerCrop | fitCenter和其他工具
请参见此处的scaleType的更多选项:
您需要将“scaleType”属性添加到布局中:看一下::我建议您使用毕加索库,既快又简单!Ref:感谢您的新知识Lege您需要在布局中添加“scaleType”属性:查看::我建议您使用毕加索库,快速简便!参考:谢谢你的新知识