下面列出了android.content.res.Configuration#SCREENLAYOUT_SIZE_XLARGE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Gets current screen size.
*
* @param context
* the context.
* @return current screen size.
*/
public static ScreenSize getCurrent(Context context) {
switch (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) {
case Configuration.SCREENLAYOUT_SIZE_SMALL:
return SMALL;
case Configuration.SCREENLAYOUT_SIZE_NORMAL:
return NORMAL;
case Configuration.SCREENLAYOUT_SIZE_LARGE:
return LARGE;
case Configuration.SCREENLAYOUT_SIZE_XLARGE:
return XLARGE;
default:
return UNDEFINED;
}
}
@SuppressLint("NewApi")
static boolean isTablet(Context context) {
if (android.os.Build.VERSION.SDK_INT > 12) {
return context.getResources().getConfiguration().smallestScreenWidthDp > 600;
} else if (android.os.Build.VERSION.SDK_INT > 10) {
int size = context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK;
return (size == Configuration.SCREENLAYOUT_SIZE_LARGE)
|| (size == Configuration.SCREENLAYOUT_SIZE_XLARGE);
} else {
return false;
}
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LinearLayout row = new LinearLayout(getContext());
row.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
final int screenSize = getResources().getConfiguration()
.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
final boolean isSmallScreen =
screenSize != Configuration.SCREENLAYOUT_SIZE_XLARGE
&& screenSize != Configuration.SCREENLAYOUT_SIZE_LARGE;
final int count = viewType == VIEW_TYPE_YEAR ? 1 : visibleMeasurements.size();
for (int i = 0; i < count; ++i) {
TextView column = new TextView(getContext());
column.setLayoutParams(new LinearLayout.LayoutParams(
0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
if (viewType == VIEW_TYPE_MEASUREMENT) {
column.setMinLines(2);
column.setGravity(Gravity.CENTER_HORIZONTAL);
if (isSmallScreen) {
column.setTextSize(COMPLEX_UNIT_DIP, 9);
}
}
else {
column.setPadding(0, 10, 0, 10);
column.setGravity(Gravity.CENTER);
column.setTextSize(COMPLEX_UNIT_DIP, 16);
}
row.addView(column);
}
return new ViewHolder(row);
}
@Override
public boolean onCreate() {
final Context context = getContext();
boolean xlargeScreenSize = (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
== Configuration.SCREENLAYOUT_SIZE_XLARGE;
boolean isPortrait = (context.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_PORTRAIT);
if (xlargeScreenSize && isPortrait) {
mMaxSuggestionLongSize = MAX_SUGGEST_LONG_LARGE;
mMaxSuggestionShortSize = MAX_SUGGEST_SHORT_LARGE;
} else {
mMaxSuggestionLongSize = MAX_SUGGEST_LONG_SMALL;
mMaxSuggestionShortSize = MAX_SUGGEST_SHORT_SMALL;
}
mOpenHelper = new DatabaseHelper(context);
mBackupManager = new BackupManager(context);
// we added "picasa web album" into default bookmarks for version 19.
// To avoid erasing the bookmark table, we added it explicitly for
// version 18 and 19 as in the other cases, we will erase the table.
if (DATABASE_VERSION == 18 || DATABASE_VERSION == 19) {
SharedPreferences p = PreferenceManager
.getDefaultSharedPreferences(context);
boolean fix = p.getBoolean("fix_picasa", true);
if (fix) {
fixPicasaBookmark();
Editor ed = p.edit();
ed.putBoolean("fix_picasa", false);
ed.apply();
}
}
mSettings = BrowserSettings.getInstance();
return true;
}
static public boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
boolean isTablet() {
return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
static public boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
@Override
public boolean onIsMultiPane() {
final int layout = getResources().getConfiguration().screenLayout;
return (layout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
static public boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}