{"id":18881000,"url":"https://github.com/nitiwari-dev/android-percent-layout-sample","last_synced_at":"2025-10-25T19:02:07.167Z","repository":{"id":88967403,"uuid":"41629005","full_name":"nitiwari-dev/android-percent-layout-sample","owner":"nitiwari-dev","description":"Note: Its build using ConstraintLayout. The sample is an alternative for nested layouts. Build to remove nested structure and create a flat xml layout, which eventually improves performance","archived":false,"fork":false,"pushed_at":"2020-08-03T15:59:22.000Z","size":126,"stargazers_count":33,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T08:22:40.460Z","etag":null,"topics":["android","android-application","android-percent-layout","android-ui","constraint-layout","constraint-programming","constraintheight","demo","example-code","layout-height-percent","layout-width-percent","library","percent","percentframelayout","relativelayout","support","xml"],"latest_commit_sha":null,"homepage":"http://www.coderconsole.com/2015/08/android-percent-support-lib-sample.html","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nitiwari-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-30T13:07:53.000Z","updated_at":"2024-05-31T08:47:47.000Z","dependencies_parsed_at":"2023-06-13T09:00:18.890Z","dependency_job_id":null,"html_url":"https://github.com/nitiwari-dev/android-percent-layout-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitiwari-dev%2Fandroid-percent-layout-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitiwari-dev%2Fandroid-percent-layout-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitiwari-dev%2Fandroid-percent-layout-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitiwari-dev%2Fandroid-percent-layout-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitiwari-dev","download_url":"https://codeload.github.com/nitiwari-dev/android-percent-layout-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248946186,"owners_count":21187464,"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","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-application","android-percent-layout","android-ui","constraint-layout","constraint-programming","constraintheight","demo","example-code","layout-height-percent","layout-width-percent","library","percent","percentframelayout","relativelayout","support","xml"],"created_at":"2024-11-08T06:46:59.555Z","updated_at":"2025-10-25T19:02:07.161Z","avatar_url":"https://github.com/nitiwari-dev.png","language":"Kotlin","readme":"[![platform](https://img.shields.io/badge/platform-Android-yellow.svg)](https://www.android.com)\n[![API](https://img.shields.io/badge/API-14%2B-brightgreen.svg?style=plastic)](https://android-arsenal.com/api?level=14)\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)\n\n# Update\nBelow example in created using `ConstraintLayout` since percent support library is deprecated from API level 26.0.0.\n\n# Integration and Example\nThis sample uses `ConstraintLayout` to build xml UI. Helps to avoid the overhead of Nested layouts and thereby improving performance.\n\nReally awesome!!!\n\n![size_1_1](https://user-images.githubusercontent.com/10304040/37208672-3542600c-23c8-11e8-92a1-32784c9e0348.png)\n![size_1_2](https://user-images.githubusercontent.com/10304040/37208806-b48731c6-23c8-11e8-9f61-d41084ef6a28.png)\n![size_1_3](https://user-images.githubusercontent.com/10304040/37208813-ba672eca-23c8-11e8-96fc-655980f68d8d.png)\n![background](https://user-images.githubusercontent.com/10304040/45996611-67a33780-c0ba-11e8-8205-eba7d06a794c.png)\n\nSteps:\n\n1. Add below into build.gradle\n\n    ` compile 'com.android.support.constraint:constraint-layout:1.1.0-beta3'`\n  \n2. Add `layout_constraintHeight_percent` and `layout_constraintWidth_percent` to specify the percentage range.\n\n3. Finally add `layout_constraintWidth_default=\"percent\"` and `layout_constraintHeight_default=\"percent\"`. Thats it !!!.\n\n```xml\n\u003candroid.support.constraint.ConstraintLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n    \u003cTextView\n        android:id=\"@+id/fifty_thirty\"\n        android:layout_width=\"0dp\"\n        android:layout_height=\"0dp\"\n        android:background=\"#ffff8800\"\n        android:gravity=\"center\"\n        android:text=\"@string/fifty_fifty_text\"\n        android:textColor=\"@android:color/white\"\n        app:layout_constraintHeight_default=\"percent\"\n        app:layout_constraintHeight_percent=\"0.5\"\n        android:textSize=\"25sp\"\n        app:layout_constraintTop_toTopOf=\"parent\"\n        app:layout_constraintWidth_default=\"percent\"\n        app:layout_constraintWidth_percent=\"0.5\" /\u003e\n\n    \u003cTextView\n        android:layout_width=\"0dp\"\n        android:layout_height=\"0dp\"\n        android:background=\"#ffff5566\"\n        android:gravity=\"center\"\n        android:text=\"@string/fifty_fifty_text\"\n        android:textColor=\"@android:color/white\"\n        android:textSize=\"25sp\"\n        app:layout_constraintHeight_default=\"percent\"\n        app:layout_constraintHeight_percent=\"0.5\"\n        app:layout_constraintLeft_toRightOf=\"@id/fifty_thirty\"\n        app:layout_constraintTop_toBottomOf=\"@id/fifty_thirty\"\n        app:layout_constraintWidth_default=\"percent\"\n        app:layout_constraintWidth_percent=\"0.5\" /\u003e\n    \n\u003c/android.support.constraint.ConstraintLayout\u003e\n```\n\nBingo we are done !!!\n\n\n## Licence\n      Copyright (C) 2020 Nitesh Tiwari.\n  \n      Licensed under the Apache License, Version 2.0 (the \"License\");\n      you may not use this file except in compliance with the License.\n      You may obtain a copy of the License at\n \n              http://www.apache.org/licenses/LICENSE-2.0\n \n      Unless required by applicable law or agreed to in writing, software\n      distributed under the License is distributed on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n      See the License for the specific language governing permissions and\n      limitations under the License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitiwari-dev%2Fandroid-percent-layout-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitiwari-dev%2Fandroid-percent-layout-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitiwari-dev%2Fandroid-percent-layout-sample/lists"}