我有一个应用程序,有不同的屏幕版本(小的,普通的,大的,extraLargue的XML文件),每种类型都有自己的XML设计,但我发现了一款华为手机,屏幕为3.5“HVGA320x480。
我的问题是,Android的UI不应该在这个屏幕上使用小配置吗?这个应用程序在这部手机上运行时会使用正常的配置,就像我更改它时使用的nexus4 4.7“768x1280一样吗?”
我尝试用多种配置创建各种类型的屏幕(创建其他),但没有得到最佳结果。
发布于 2016-09-13 05:06:14
假设3.5英寸的尺寸在对角线上,根据Android的支持多屏幕指南,这大约是165dpi,落入mdpi (或正常屏幕尺寸)桶中。
DPI = sqrt(w^2 + h^2) / d
where
w is the width of the display in pixels
h is the height of the display in pixels
d is the physical diagonal measurement of the display in inches发布于 2016-09-13 04:47:59
这很简单。
您需要添加不同的UI,并将控件设置为VISIBILE和GONE。
int appScreen = getResources().getConfiguration().screenLayout &
Configuration.SCREENLAYOUT_SIZE_MASK;
switch(appScreen) {
case Configuration.SCREENLAYOUT_SIZE_LARGE:
UIControl.setVisibility(View.GONE);
break;
case Configuration.SCREENLAYOUT_SIZE_NORMAL:
UIControl.setVisibility(View.GONE);
break;
case Configuration.SCREENLAYOUT_SIZE_SMALL:
UIControl.setVisibility(View.GONE);
break;
default:
UIControl.setVisibility(View.GONE);
}https://stackoverflow.com/questions/39458303
复制相似问题