Android即可办理所有设备屏幕的最佳实践 [英] Android best practice to handle all devices screens
问题描述
我知道有很多讨论这个话题,因为它重要,我有一些问题。
所有的开发人员我将我的DIVID主题,以多点
文字大小
块引用>哪种方式更好地处理所有文本的大小在所有屏幕?
的经code 的
mTextView.setTextSize(16 * getResources()getDisplayMetrics()密度);
的处理不同尺寸的
通过创建
dimens.xml
中的值的默认文件夹放在<扪NAME =FONT_SIZE> 14sp< /扪>
和
dimens.xml
中的价值观大的星系选项卡1。<扪NAME =FONT_SIZE>&20SP LT; /扪> //把你想要的大小
和
dimens.xml
中的价值观sw600dp 的平板<扪NAME =FONT_SIZE> 30sp< /扪>
引用它在你看来
的android:TEXTSIZE =@梦诗/ FONT_SIZE
浏览
块引用>通过改变宽度,高度动态
或创建多布局
布局sw320dp
布局sw480dp
布局sw600dp
布局sw720dp我想知道每个布局重新present喜欢布局sw320dp到小屏幕像Nexus One的?
任何一个可以指导我怎么能很好的方式做到这一点。
解决方案好,我已经做到了我的项目的东西使用的
SDP
,它会调整你的的TextView大小的值
(例如)为每个设备。如果您正在使用
Android的工作室
的这很容易使用,你只需要在你的
的build.gradle添加这个(模块:应用程序)
{相关性
编译com.intuit.sdp:SDP-安卓1.0.2
}如果您正在使用
的Eclipse ADT
的您只需要为一个库中添加
SDP
到项目中。下面是一个简单的例子,如何使用它:的例
基本上你,而不是添加
SP
,DP
等..你需要使用SDP
。希望它帮助。
I know there are a lot of discussion about this topic as it important to all developers I have some question
I will divid my topic to many points
Text Size
which way better to handle all text sizes in all screens ?
Via code
mTextView.setTextSize(16 * getResources().getDisplayMetrics().density);
handle different dimensions
By creating
dimens.xml
in values folder for default put<dimen name="font_size">14sp</dimen>
and
dimens.xml
in values-large for galaxy tab 1.<dimen name="font_size">20sp</dimen> // put any size you want
and
dimens.xml
in values-sw600dp for tablet<dimen name="font_size">30sp</dimen>
reference it in your view
android:textSize="@dimens/font_size"
Views
by changing width , height dynamically
or by creating multi layouts
layout-sw320dp layout-sw480dp layout-sw600dp layout-sw720dp
I want to know what each layout represent to like layout-sw320dp to small screen like nexus one ?
can any one guide me how can I do this in nice way
解决方案Well the thing that I've done it on my projects is using
sdp
, it will resize the values of yourTextview size
(for example) for each device.If you are using
Android Studio
It's easy to use, you only have to add this in your
build.gradle(Module: app)
dependencies { compile 'com.intuit.sdp:sdp-android:1.0.2' }
If you are using
Eclipse ADT
You'll only need to add
sdp
as a library to your project.Here is an easy example to how to use it : Example
Basically you instead of add
sp
,dp
, etc... you'll need to usesdp
.Hope it helps.
这篇关于Android即可办理所有设备屏幕的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!