Xcode 快捷键

多行缩进

cmd + [
cmd + ]

行首末跳转

cmd + <
cmd + >

删除行

cmd + del

Android 使用 Zxing 创建二维码

public final class genQrCode {
	private static final int BLACK = 0xff000000;
	
	public static Bitmap createQRCode(String str,int widthAndHeight) throws WriterException {
		Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();  
        hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); 
		BitMatrix matrix = new MultiFormatWriter().encode(str,
				BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight);
		int width = matrix.getWidth();
		int height = matrix.getHeight();
		int[] pixels = new int[width * height];
		//在相应的位置填充黑色
		for (int y = 0; y < height; y++) {
			for (int x = 0; x < width; x++) {
				if (matrix.get(x, y)) {
					pixels[y * width + x] = BLACK;
				}
			}
		}
		Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
		bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
		return bitmap;
	}
}

基于 HTTP 协议的流媒体对比

Alt none

Android 使用 StaticLayout 实现字符串换行

static class LongTextView extends View {
        private static final float TEXT_SIZE = 60;

        private static final CharSequence TEXT = "This is a long long long " +
                "long long long long long long long long long long " +
                "long long long string";

        TextPaint textPaint;

        public LongTextView(Context context) {
            super(context);
            textPaint = new TextPaint();
            textPaint.setColor(Color.BLUE);
            textPaint.setStyle(Paint.Style.FILL);
            textPaint.setTextSize(TEXT_SIZE);
        }

        public void onDraw(Canvas canvas) {
            super.onDraw(canvas);

            StaticLayout staticLayout = new StaticLayout(
                    TEXT, textPaint,
                    canvas.getWidth(),
                    Layout.Alignment.ALIGN_NORMAL,
                    1.0f, 0.0f, false
            );

            staticLayout.draw(canvas);
        }
    }

Android Studio 鼠标暂停显示帮助文档

Alt none