简体   繁体   English

以编程方式为Android设置布局

[英]Programmatically set layout for android

I am trying to improve the layout for my game. 我正在尝试改善游戏的布局。 The problem is that while I can create a 问题是,尽管我可以创建一个

good layout for one android phone, it doesn't work for another, ie the trackball for MyTouch 一款Android手机的布局很好,但不适用于另一款,即MyTouch的轨迹球

is on the right side (landscape mode), but for the MyCliq, the DPad is on the left side. 位于右侧(横向模式),但对于MyCliq,DPad位于左侧。 Is

there a way to programmatically set the layout based on which phone it is? 有没有一种方法可以根据手机类型来编程设置布局? Thanks. 谢谢。

虽然不是编程的,也不是特定于电话的,但是您可以提供替代的布局资源 ,这些资源会根据设备是否具有DPad或轨迹球自动加载。

If you really wanted to do it on a device specific basis, perhaps android.os.Build.DEVICE would help. 如果您确实想在特定设备上执行此操作,那么android.os.Build.DEVICE可能会有所帮助。

http://developer.android.com/reference/android/os/Build.html#DEVICE http://developer.android.com/reference/android/os/Build.html#DEVICE

I haven't tried it but perhaps it will help 我没有尝试过,但也许会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM