Android枚舉方案
- 方法中限制參數範圍
public void setNumber(@IntRange(from = 0, to = 100) int number) {
}
- 方法參數限制參數值
@IntDef({RED, GREEN})
@Retention(RetentionPolicy.SOURCE)
public @interface Color{}
private static final int RED = 1;
private static final int GREEN = 2;
public void setColor(@Color int color) {
}
獲取View的截圖
View viewRoot = getWindow().getDecorView().getRootView();
viewRoot.setDrawingCacheEnabled(true);
Bitmap screenShotAsBitmap = Bitmap.createBitmap(viewRoot.getDrawingCache());
viewRoot.setDrawingCacheEnabled(false);
// use screenShotAsBitmap as you need