提高图像的Andr​​oid应用程序的大小 [英] Increase the size of Image in android app

查看:195
本文介绍了提高图像的Andr​​oid应用程序的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Andr​​oid应用程序附加一个图像,但是当我启动应用程序是非常small.Please建议如何提高应用程序的大小,使其清晰可见。

下面的代码片段code我的 activity_main.xml中

 < ImageView的
    机器人:ID =@ + ID / power_image
    机器人:SRC =@的mipmap / ic_launcher
    机器人:layout_width =200dp
    机器人:layout_height =200dp
    机器人:layout_above =@ + ID / logBu​​tton
    机器人:scaleType =fitCenter
    机器人:layout_alignParentRight =真
    机器人:layout_alignParentEnd =假
    机器人:知名度=看得见
     />


解决方案

您scaleType更改为 centerCrop 并它将工作。 这里是关于Android的ScaleType在ImageView的全面指导。以下是所有最常见的类型scaleType的列表:


  

中心:显示在没有缩放视图中心的图片


  
  

<强> centerCrop :缩放图像,使得这两个x和y尺寸大于或等于所述视图,同时保持
  图像纵横比;在视图中居中图像


  
  

centerInside 缩放图像以适合视图内,同时保持图像纵横比。如果图像是已经小
  比视图,那么这是相同的中心


  
  

fitCenter 缩放图像以适合视图内,同时保持图像纵横比。至少一个轴将准确
  匹配视图,其结果为中心的视图内。


  
  

fitStart 同fitCenter但对齐到视图的左上角。


  
  

fitEnd 同fitCenter但对齐到视图的右下方。


  
  

fitXY 缩放X和Y尺寸视图尺寸完全匹配;不保持图像的纵横比。


  
  

矩阵秤使用所提供的Matrix类的形象。矩阵可以使用setImageMatrix方法来提供。一个Matrix类可以是
  用于施加变换,如旋转到图像


I have attached a image in my android app but when i launch the app it is very small.Please suggest how to increase its size in app so that its clearly visible.

Below is the snippet code of my activity_main.xml :

 <ImageView
    android:id="@+id/power_image"
    android:src="@mipmap/ic_launcher"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_above="@+id/logButton"
    android:scaleType="fitCenter"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="false"
    android:visibility="visible"
     />

解决方案

Change your scaleType to centerCrop and it will be worked. Here is full guide about ScaleType in ImageView in Android. The following is a list of all the most common types of scaleType:

center : Displays the image centered in the view with no scaling.

centerCrop : Scales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; centers the image in the view.

centerInside Scales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center.

fitCenter Scales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view.

fitStart Same as fitCenter but aligned to the top left of the view.

fitEnd Same as fitCenter but aligned to the bottom right of the view.

fitXY Scales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio.

matrix Scales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

这篇关于提高图像的Andr​​oid应用程序的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆