這兩天一在看動畫這一塊,在我心中,這種東西是好高級的東西啊,看不懂,但總要有動手的時候吧,看了大神的動畫後,這就先來試手了,這個我覺得還不錯 - -,希望我過段時間這動畫能夠隨手捏來啊!!! ^^^^^
源代碼是用Eclipse寫的,別導入Studio了啊
整片代碼,其實就下面一段是核心
bitmapShader = new BitmapShader(image, TileMode.CLAMP, TileMode.CLAMP);
float scale = 1.0f;
int size = Math.min(image.getWidth(), image.getHeight());
scale = getWidth() * 1.0f / size;
// 設置縮放比例
matrix.setScale(scale, scale);
// 設置旋轉角度
matrix.postRotate(degree, getWidth() / 2, getHeight() / 2);
// 加載變換矩陣
bitmapShader.setLocalMatrix(matrix);
// 設置shader
paint.setShader(bitmapShader);
注意到了將圖片縮放與旋轉,然後開個線程來刷新實現效果
- 下載源碼點這裏