{"id":3185,"date":"2014-03-19T11:19:16","date_gmt":"2014-03-19T11:19:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/19\/gradient-radius-as-percentage-of-screen-size-collection-of-common-programming-errors\/"},"modified":"2014-03-19T11:19:16","modified_gmt":"2014-03-19T11:19:16","slug":"gradient-radius-as-percentage-of-screen-size-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/19\/gradient-radius-as-percentage-of-screen-size-collection-of-common-programming-errors\/","title":{"rendered":"Gradient Radius as percentage of screen size-Collection of common programming errors"},"content":{"rendered":"<p>I ended up creating a custom View with following overriden onDraw method:<\/p>\n<pre><code>@Override\nprotected void onDraw(Canvas canvas) {\n    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);\n\n    int maxSize = Math.max(getHeight(), getWidth());\n    RadialGradient gradient = new RadialGradient(\n            getWidth()\/2,\n            getHeight()\/2,\n            maxSize, \n            new int[] {Color.RED, Color.BLACK},\n            new float[] {0, 1}, \n            android.graphics.Shader.TileMode.CLAMP);\n\n    paint.setDither(true);\n    paint.setShader(gradient);\n\n    canvas.drawRect(0, 0, getWidth(), getHeight(), paint);\n}\n<\/code><\/pre>\n<p>In your layout just add the View:<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>Of course it would be possible to create attributes for the View, eg. color, percentage to allow customization via XML.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I ended up creating a custom View with following overriden onDraw method: @Override protected void onDraw(Canvas canvas) { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); int maxSize = Math.max(getHeight(), getWidth()); RadialGradient gradient = new RadialGradient( getWidth()\/2, getHeight()\/2, maxSize, new int[] {Color.RED, Color.BLACK}, new float[] {0, 1}, android.graphics.Shader.TileMode.CLAMP); paint.setDither(true); paint.setShader(gradient); canvas.drawRect(0, 0, getWidth(), getHeight(), paint); } In your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3185","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3185"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3185\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}