适用于所有android设备的响应式设计 [英] Responsive design for all android devices

查看:86
本文介绍了适用于所有android设备的响应式设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用两种不同的方法在android设备中实现响应式设计

I am using two different methods to achieve responsive design in android devices

方法1.我在不同的文件夹(例如

Method 1. I used different dimens.xml in different folders like

values-hdpi
values-ldpi
values-mdpi
values-xhdpi  
values-xxhdpi


方法2.我将所有布局复制到


Method 2. I copied all my layouts to

layout
layout-large
layout-small
layout-xlarge

文件夹,并且具有不同的高度,宽度和其他

folders and given different heights, widths and other

当我使用第一种方法时,我没有得到正确的响应式设计,而当我使用第二种方法时,我得到了正确的设计,但它增加了应用程序的大小.

When I use the first method I am not getting the correct responsive design and when I use the second method I am getting the correct design but it increasing the application size.

所以,请告诉我,除了我的两种方法之外,实现100%响应式设计的最佳过程.

So, please tell me the best process to achieve 100% responsive design other than my two methods

推荐答案

我通常去valuesvalues-large,...文件夹,然后在其中放置dimens.xml文件,在此我为每个屏幕指定大小尺寸类别. values是后备",如果我没有为特定尺寸类别指定任何内容,则它包含默认值. 在布局中,我像这样使用它:

I usually go for the values, values-large, ... folders and put dimens.xml files there, where I specify the sizes for each screen size category. The values is the "fallback", it contains the default value if I don't specify any for a specific size category. In the layouts I use it like this:

android:width="@dimen/width_for_this_view"

values/dimens.xml中定义:

<dimen name="width_for_this_view">30dp</dimen>

您可以为不同的values(大,中,小,..)文件夹定义不同的大小.

You can define different sizes for different values (large, normal, small, ..) folder.

这篇关于适用于所有android设备的响应式设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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