gpt4 book ai didi

android - 如何知道我是否应该在布局中使用 ldpi

转载 作者:行者123 更新时间:2023-11-29 21:08:28 25 4
gpt4 key购买 nike

大家好,我正在努力实现多屏幕支持。是否有类似案例?

 @Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.contatti);

//if (device in use , use ldpi ) { do something
else{


Button btnNavigator = (Button) findViewById(R.id.btnNavigator);

GoogleMap map=((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
map.moveCamera(CameraUpdateFactory.newLatLngZoom(STARTING_POINT, 5));

非常感谢。你能给我举个例子吗?

最佳答案

试试这段代码:

private final boolean isLdpi()
{
final DisplayMetrics metrics =
Resources.getSystem().getDisplayMetrics();

final float scale = metrics.density;

return (scale == 0.75); // ldpi = 0.75, mdpi = 1.0, hdpi = 1.5, xhdpi = 2.0, xxhdpi = 3.0, ...
}

用法:

if (isLdpi)
{
// It's ldpi: do something
}

关于android - 如何知道我是否应该在布局中使用 ldpi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23714504/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com