安卓:在XML调整的ImageViewXML、ImageView

2023-09-04 06:13:30 作者:溫柔尝尽了吗

我有一个形象,是太大,无法在屏幕上,我希望它相当小的屏幕上。我如何通过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"

 
精彩推荐
图片推荐