{"id":21040728,"url":"https://github.com/l-briand/shadowlayout","last_synced_at":"2025-08-02T19:07:19.137Z","repository":{"id":57737562,"uuid":"274785301","full_name":"L-Briand/ShadowLayout","owner":"L-Briand","description":"A CSS like shadow in android","archived":false,"fork":false,"pushed_at":"2021-06-01T21:48:20.000Z","size":226,"stargazers_count":143,"open_issues_count":3,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-15T16:43:19.185Z","etag":null,"topics":["android","android-custom-view","android-library","shadow"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/L-Briand.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-24T22:57:19.000Z","updated_at":"2025-05-06T22:29:15.000Z","dependencies_parsed_at":"2022-08-24T10:52:12.570Z","dependency_job_id":null,"html_url":"https://github.com/L-Briand/ShadowLayout","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/L-Briand/ShadowLayout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-Briand%2FShadowLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-Briand%2FShadowLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-Briand%2FShadowLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-Briand%2FShadowLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/L-Briand","download_url":"https://codeload.github.com/L-Briand/ShadowLayout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-Briand%2FShadowLayout/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268439043,"owners_count":24250667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-custom-view","android-library","shadow"],"created_at":"2024-11-19T13:47:48.917Z","updated_at":"2025-08-02T19:07:19.112Z","avatar_url":"https://github.com/L-Briand.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ShadowLayout a css like shadow for android\n\nHave you ever wanted a CSS type of shadow in your Android project ? No?! Me neither but designers\nkeep using it and the death flag is triggered when the app isn't a copy of the design. So, there it goes.\n\nIt do much more than casting a shadow so the name can be inaccurate. Internally, it uses the native \n`ScriptIntrinsicBlur` render script so it can easily blur the whole layout like the\n[Blurry](https://github.com/wasabeef/Blurry) library.\n\n# Requirements\n\nAndroid 5.+ (API 21)\n\n# Gradle\n\nThe project is hosted on maven Central :\n```groovy\nallprojects {\n    repositories {\n        mavenCentral()\n    }\n}\n```\n\nThen add dependency :\n```groovy\ndependencies {\n    implementation(\"net.orandja.shadowlayout:shadowlayout:1.0.1\")\n}\n```\n\n\n# Usage\n\nAdd `android:clipChildren=\"false\"`, `android:clipToPadding=\"false\"` to the parent layout to let ShadowLayout draw outside of view bounds.\n\n```xml\n\u003cnet.orandja.shadowlayout.ShadowLayout\n    android:padding=\"8dp\"\n    android:layout_gravity=\"center\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:background=\"@drawable/round_corners\"\n    app:shadow_radius=\"8\"\n    app:shadow_x_shift=\"-1dp\"\n    app:shadow_y_shift=\"2dp\"\n    app:shadow_downscale=\"1\"\n    app:shadow_color=\"#808\"\n    app:shadow_with_foreground=\"true\"\n    app:shadow_with_color=\"false\"\n    app:shadow_with_dpi_scale=\"true\"\n    app:shadow_with_css_scale=\"true\"\n    app:shadow_cast_only_background=\"true\"\u003e\n\n    \u003candroidx.appcompat.widget.AppCompatTextView\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:textColor=\"@color/black\"\n        android:text=\"The quick brown fox jump over the lazy dog\"\n        android:textSize=\"16sp\" /\u003e\n\n\u003c/net.orandja.shadowlayout.ShadowLayout\u003e\n```\n\n![quick brown fox text view](assets/quick_fox.png)\n\n## Parameters\n\nDefault value in parenthesis\n\n- `shadow_radius` (6f) The radius of the gaussian blur in float. See #Rules of downscaling section to see how it works. \n- `shadow_x_shift` (0dp) Shift on the horizontal axis in dp\n- `shadow_y_shift` (0dp) Shift on the vertical axis in dp\n- `shadow_color` (#33000000) Color of the casted shadow\n- `shadow_downscale` (1f) Downscale of the internal bitmap that render the shadow. The higher the downscale, the lower in size is the bitmap. At 2, the size of bitmap is halved. \n- `shadow_with_foreground` (true) Draw the actual view on top of the shadow.\n- `shadow_with_color` (false) Keep all the subview colors in the blur. Coupled with `shadow_with_foreground` at false, a blur image can be render on screen.\n- `shadow_with_dpi_scale` (true) Downscale the internal bitmap by the current smartphone dpi. A 100dp view will result in a 100px bitmap. \n- `shadow_with_css_scale` (true) Downscale by 5/3 more. Because CSS shadow standard blur by a half more than the real blur size.\n- `shadow_cast_only_background` (false) Only render the background and not the view as shadow\n\n\n## Limitations\n\nThe default implementation of android gaussian blur (`ScriptIntrinsicBlur` render script) is limited to 25 pixels at max. \nTo counter that, the layout downscale the real render of the view inside a bitmap (ALPHA_8 or RGBA with `shadow_with_color` at true). \nThen blur it. Then renders the blur inside the canvas. Then **redraw** the view in the canvas. (`shadow_with_foreground` at true)\n\nThe radius can mean multiple things depending on the configurations. \n\n## Rules of downscaling\n\nWhen no downscale are applied:\n \n```xml\n\u003cnet.orandja.shadowlayout.ShadowLayout\n    app:shadow_radius=\"3f\"\n    app:shadow_downscale=\"1\"\n    app:shadow_with_dpi_scale=\"false\"\n    app:shadow_with_css_scale=\"false\" /\u003e\n```\n\nThe internal bitmap is the same size of the view. The radius is the number of **pixels** blured around.\nWith high dpi, it will be hard to see the effect. However, in some cases, it can be usefull to have a nice looking blur at the expense of more memory.\nThe max radius is 25 pixels. The parameter `shadow_downscale` multiply the max radius by its value. So at shadow_downscale=\"2.5\" it increases the max radius to 62.5f.\n\nWhen `app:shadow_with_dpi_scale=\"true\"`: Downscale the internal bitmap by the current smartphone dpi. A 100dp view will result in a 100px bitmap.\nThe radius means **dp**. It blurs up to 25dp.\n\nWhen `app:shadow_with_css_scale=\"true\"`: Same as dpi, it will add a 5/3 downscale to mimic the CSS shadow blur.\n\n# Shadow anything\n\nAs said before since it draw the whole layout it can cast a shadow of anything. Like text:\n\n```xml\n    \u003cnet.orandja.shadowlayout.ShadowLayout\n        android:padding=\"8dp\"\n        android:layout_gravity=\"center\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        app:shadow_radius=\"1\"\n        app:shadow_x_shift=\"1dp\"\n        app:shadow_y_shift=\"2dp\"\n        app:shadow_downscale=\"1\"\n        app:shadow_color=\"#AA000000\"\n        app:shadow_with_foreground=\"true\"\n        app:shadow_with_color=\"true\"\n        app:shadow_with_css_scale=\"false\"\n        app:shadow_with_dpi_scale=\"true\"\n        app:shadow_cast_only_background=\"true\"\u003e\n\n        \u003candroidx.appcompat.widget.AppCompatTextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:textColor=\"#808\"\n            android:text=\"The quick brown fox jump over the lazy dog\"\n            android:textSize=\"16sp\" /\u003e\n\n    \u003c/net.orandja.shadowlayout.ShadowLayout\u003e\n```\n\n![quick brown fox text view](assets/quick_fox_text.png)\n\nSince `shadow_with_color` is at true, the drawn shadow is of the same color of the text rendered.\nThe color parameter only affect alpha. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl-briand%2Fshadowlayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fl-briand%2Fshadowlayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl-briand%2Fshadowlayout/lists"}