Different GUI on phone and tablet, but same app

前端 未结 1 540
我寻月下人不归
我寻月下人不归 2021-01-05 22:45

I have to write an app for tablet and for phones too. The two app has the same functionality, but they have absolute different GUI.

For example the phone have 2 but

1条回答
  •  执笔经年
    2021-01-05 23:24

    Put your tablet layouts in res/layout-large/. Put your phone layouts in res/layout/. Name them the same. Your activities will load the right ones based upon the device they run on. When you call findViewById() to retrieve the extra buttons, and see that you get null back, ignore them.

    You may need additional layouts in places like res/layout-large-land/ (landscape for tablets), res/layout-xlarge/ (if you want to handle 10+" tablets differently than stuff in the 5-9" range), res/layout-small/ (if you want to handle <3" screens), etc.

    0 讨论(0)
提交回复
热议问题