手机和平板电脑的ImageView大小 [英] ImageView size for phones and tablets

查看:89
本文介绍了手机和平板电脑的ImageView大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的应用制作仪表板之类的东西.一切正常,除了ImageView大小适合不同设备屏幕英寸的情况.

I'm making something like a dashboard for my app. And everything fine except situation with ImageView size for diffrent device's screen inch.

在7英寸及以下的手机和设备上看起来不错

但是在7英寸以上的设备上,它看起来很糟糕

在所有情况下,我都使用相同大小的ImageView-50dp,并且生成了MDPI,HDPI,XHDPI,XXHDPI图像

In all cases I used same size of ImageView - 50dp and I have generate MDPI, HDPI, XHDPI, XXHDPI images

如果我使用减光,我将得到模糊的图像,因为MDPI,HDPI,XHDPI,XXHDPI图像仅针对50dp生成,而不会针对100dp生成

If I will use dimens I will get blured images because MDPI, HDPI, XHDPI, XXHDPI images will be generated only for 50dp, but not for 100dp

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="image_size">100dp</dimen>
</resources>

但是看起来7英寸或更大英寸的设备需要更大的图像尺寸,例如100dp.

But seems devices with 7" and more inch needs a little more image size, for example, 100dp.

我无法搜索解决方案. 是否可以在不创建额外代码的情况下使图片在7英寸以上的平板电脑上看起来更大?

I can't googling the solution. Is it possible to make images looks bigger on 7"+ tablets while not creating extra code?

推荐答案

令人惊讶且非常奇怪的是,没人能回答这个看似简单的问题.好吧,我偶然发现了一个解决方案,它很简单

It is surprising and very strange that no one could give an answer to this seemingly simple question. Well, accidentally I found a solution and it was just as simple

如果您想为平板电脑和手机显示不同的图像尺寸,只需为其创建一个dimen

If you want show different image sizes for tablet and phones just create an dimen for it

对于手机,我们显示50dp的小图片

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="image_size">50dp</dimen>
</resources>

对于10英寸左右的平板电脑,我们以100dp显示2倍大小的图像

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="image_size">100dp</dimen>
</resources>

然后在ImageView标记中指定大小:

Then in ImageView tag specify size:

<ImageView
    android:layout_width="@dimen/image_size"
    android:layout_height="@dimen/image_size"
    android:id="@+id/imgViewIcon"/>

因此,您必须为手机制作与原始大小50dp不同的密度图像,并将其放入MDPI,HDPI,XHDPI,XXHDPI文件夹中.对于平板电脑,以100dp制作图像并生成不同密度的图像,然后将其放在 drawable-wNNNdp-?dpi 文件夹中,其中 NNN -屏幕宽度和?- l,m,h,xh,xxh,xxxh dpi.正是文件夹 drawable-wNNNdp-?dpi 是答案

And necessarily you must make images for phones for different density from original size 50dp and put them in MDPI, HDPI, XHDPI, XXHDPI folders. For tablet make image with 100dp and also generate for different density, then put it in drawable-wNNNdp-?dpi folders, where NNN - screen width and ? - l, m, h, xh, xxh, xxxh dpi. Exactly folders drawable-wNNNdp-?dpi is the answer

这篇关于手机和平板电脑的ImageView大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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