本文介绍了安卓:在XML调整的ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个形象,是太大,无法在屏幕上,我希望它相当小的屏幕上。我如何通过XML改变图像的大小?
I have an image that is too big to fit on the screen, i want it fairly small on screen. How do i change the size of the image through XML?
我想:
<ImageView
android:id="@+id/image"
android:layout_width = "100dp"
android:layout_height= "100dp"
android:scaleType="center"
android:layout_gravity="center_horizontal|bottom"
android:src="@drawable/dashboard_rpm_bottom"
>
</ImageView>
但图像没有调整......它被裁剪。任何想法?
but the image isn't resized...it gets cropped. Any ideas?
推荐答案
例如:
<ImageView android:id="@+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:maxWidth="42dp"
android:maxHeight="42dp"
android:scaleType="fitCenter"
android:layout_marginLeft="3dp"
android:src="@drawable/icon"
/>
添加属性机器人:scaleType =fitCenter和android:adjustViewBounds =真正的
Add property android:scaleType="fitCenter" and android:adjustViewBounds="true"
这篇关于安卓:在XML调整的ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!