Portrait for phone, landscape for Tablet (Android-Layout)

后端 未结 5 1691
臣服心动
臣服心动 2020-11-30 04:09

So I\'m making an application for Android and I want to force Landscape orientation for tablets and Portrait orientation for phones. However, it seems as though I can only

5条回答
  •  失恋的感觉
    2020-11-30 04:46

    set a layout called llTablet on the layout menu in the "layout-large" folder layouts and a llPhone layout on the layout menu in the "layout" folder. By menu am refering to the first layout the user is entering. Then check if you can reference it. If you can't reference llPhone then its a tablet.

    llPhone = (LinearLayout) findViewById (R.id.llPhone)
    if (llPhone == null) {
     tablet = true;
    }
    else {
     tablet = false;
    }
    

提交回复
热议问题