Android开发规范

Android开发规范

官方规范

地址: https://source.android.com/source/code-style

补充

  1. ndk开发: native方法方法名以"native"开头,并遵循小驼峰命名法,且命名中不要包含'_'.

    例如,以下示例来自Bitmap.java:

    private static native Bitmap nativeCreateFromParcel(Parcel p);
    

    Canvas同时存在两种方式,比较混乱:

    private native void native_drawBitmap(long nativeCanvas,
            Bitmap bitmap,
            float srcLeft, float srcTop, float srcRight, float srcBottom,
            float dstLeft, float dstTop, float dstRight, float dstBottom,
            long nativePaintOrZero, int screenDensity, int bitmapDensity);
            
    private static native void native_drawBitmap(long nativeCanvas, int[] colors,
            int offset, int stride, float x,
            float y, int width, int height,
            boolean hasAlpha,
            long nativePaintOrZero);
    
  2. native方法全部使用private修饰符,通过使用java方法调用.

posted @ 2018-04-23 22:48  diql  阅读(128)  评论(0编辑  收藏  举报