diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..d66561f Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 4716600..13c4629 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,5 @@ - - - - - - - - - - - - - - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 328648b..29b9131 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,7 @@ + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index f3ab172..2a48ee6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 + compileSdkVersion 24 buildToolsVersion "25.0.3" defaultConfig { applicationId "com.hencoder.hencoderpracticedraw2" @@ -20,7 +20,7 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) diff --git a/app/src/main/java/com/hencoder/hencoderpracticedraw2/practice/Practice01LinearGradientView.java b/app/src/main/java/com/hencoder/hencoderpracticedraw2/practice/Practice01LinearGradientView.java index 26596b1..34350f0 100644 --- a/app/src/main/java/com/hencoder/hencoderpracticedraw2/practice/Practice01LinearGradientView.java +++ b/app/src/main/java/com/hencoder/hencoderpracticedraw2/practice/Practice01LinearGradientView.java @@ -3,13 +3,16 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.LinearGradient; import android.graphics.Paint; +import android.graphics.Shader; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.View; public class Practice01LinearGradientView extends View { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + Shader shader = new LinearGradient(100,100,500,500,Color.parseColor("#E91E63"),Color.parseColor("#2196F3"),Shader.TileMode.CLAMP); public Practice01LinearGradientView(Context context) { super(context); @@ -24,6 +27,13 @@ public Practice01LinearGradientView(Context context, @Nullable AttributeSet attr } { + /** + * LinearGradient(float x0, float y0, float x1, float y1, int color0, int color1, Shader.TileMode tile) 。 + + 参数: + x0 y0 x1 y1:渐变的两个端点的位置 + color0 color1 是端点的颜色 + */ // 用 Paint.setShader(shader) 设置一个 LinearGradient // LinearGradient 的参数:坐标:(100, 100) 到 (500, 500) ;颜色:#E91E63 到 #2196F3 } @@ -31,7 +41,7 @@ public Practice01LinearGradientView(Context context, @Nullable AttributeSet attr @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); - + paint.setShader(shader); canvas.drawCircle(300, 300, 200, paint); } }