[Android] 偵測screen size的方法

Configuration conf = this.getResources().getConfiguration(); 
        if((conf.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL){
         Toast.makeText(getBaseContext(), "SCREENLAYOUT_SIZE_SMALL" , Toast.LENGTH_LONG).show();
        }
        
        else if((conf.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL){
         Toast.makeText(getBaseContext(), "SCREENLAYOUT_SIZE_NORMAL" , Toast.LENGTH_LONG).show();
        }
        
        else if((conf.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE){
         Toast.makeText(getBaseContext(), "SCREENLAYOUT_SIZE_LARGE" , Toast.LENGTH_LONG).show();
        }

留言

這個網誌中的熱門文章

手動關閉Alert組件的方法

Flex的官方文件

Android ADT 21.0.1 Bug