我正在为我的嵌入式项目开发 android 应用程序,我对 android 非常陌生。我开发的 UI 应该适用于 android 中的所有类型的屏幕(所有分辨率)。
下面是我的各种分辨率的代码:
if ( ((width>=240)&&(width<=320))&&((height>=320)&&(height<=480)) )
{
setContentView(R.layout.xsmall_layout);
}
else if( ((width>=360)&&(width<=480))&&((height>=640)&&(height<=720)) )
{
setContentView(R.layout.small_layout);
}
else if ( ((width>=480)&&(width<=540))&&((height>720)&&(height<=960)) )
{
setContentView(R.layout.medium_layout);
}
else if ( ((width>540)&&(width<=800))&&((height>=1024)&&(height<=1280)) )
{
setContentView(R.layout.vlarger_layout);
}
else if ( ((width>800)&&(width<=1080))&&((height>=1280)&&(height<=1920)) )
{
setContentView(R.layout.x_vlarger_layout);
}
else if ( ((width>=800)&&(width<=1024))&&((height>=480)&&(height<600)) )
{
setContentView(R.layout.wlarger_layout);
}
else if ( ((width>=1024)&&(width<=1280))&&((height>=600)&&(height<=800)) )
{
setContentView(R.layout.x_wlarger_layout);
}
else if ( ((width>=1280)&&(width<=2560))&&((height>800)&&(height<=1600)) )
{
setContentView(R.layout.xx_wlarger_layout);
}
它工作正常,但这是一个好习惯吗?在我的电脑(英特尔双核,2GB RAM)中,代码中的最后一个分辨率不起作用。我试过 1920x1200 和 2560x1600 。Android模拟器只是没有运行。只是它即将到来的黑屏。这是我的电脑问题还是什么..?帮帮我前辈......