I have an activity that has two layouts one in the folder layout
and the other one in
layout-large
, (one is for the phone factor and the other one for the tablet form). How
do I detect which layout is being loaded since in the tablet 开发者_运维知识库form I display more data?
Thanks
EDIT:
I know that in the tablet it will load the layout-large
but how do I know that I am running in something with a tablet form factor?
You can detect it programmatically:
(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
and with other methods and properties in getResources().getConfiguration()
A simple approach would be to keep a Text view with visibility set as GONE. Keep text property for each layout different. In your code check for this view and identify which layout has been loaded.
精彩评论