{"id":21130272,"url":"https://github.com/mapleqin/Android-RatioLayout","last_synced_at":"2025-07-09T01:33:00.113Z","repository":{"id":36064461,"uuid":"40363441","full_name":"mapleqin/Android-RatioLayout","owner":"mapleqin","description":"This is a specified proportion to the size of the Layout or View support library, with which you can easily set a fixed ratio of the size of the Layout or View, internal adaptive size calculation, completely abandon the code to calculate the size! If you have any questions in the course or suggestions, please send an e-mail to the following e-mail, thank you!","archived":false,"fork":false,"pushed_at":"2023-08-30T03:27:45.000Z","size":12070,"stargazers_count":461,"open_issues_count":1,"forks_count":71,"subscribers_count":10,"default_branch":"master","last_synced_at":"2023-11-07T16:09:54.294Z","etag":null,"topics":["android","android-ratiolayout","autolayout","ratio","ratiolayout"],"latest_commit_sha":null,"homepage":"https://mapleqin.org/Android-RatioLayout/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mapleqin.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":"2015-08-07T14:08:00.000Z","updated_at":"2023-09-15T06:09:22.000Z","dependencies_parsed_at":"2022-08-17T18:55:14.505Z","dependency_job_id":null,"html_url":"https://github.com/mapleqin/Android-RatioLayout","commit_stats":null,"previous_names":[],"tags_count":2,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapleqin%2FAndroid-RatioLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapleqin%2FAndroid-RatioLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapleqin%2FAndroid-RatioLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapleqin%2FAndroid-RatioLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mapleqin","download_url":"https://codeload.github.com/mapleqin/Android-RatioLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225476370,"owners_count":17480215,"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-ratiolayout","autolayout","ratio","ratiolayout"],"created_at":"2024-11-20T05:32:30.352Z","updated_at":"2024-11-20T05:32:40.023Z","avatar_url":"https://github.com/mapleqin.png","language":"Java","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"# Deprecated ⚠️⚠️⚠️\nThis project has stopped maintenance, now there is a better solution, please refer to [ConstraintLayout](https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout)\n\n# Android-RatioLayout [![Build Status](https://travis-ci.org/amphiaraus/Android-RatioLayout.svg)](https://travis-ci.org/amphiaraus/Android-RatioLayout) [ ![Download](https://api.bintray.com/packages/soulwolf/maven/ratiolayout/images/download.svg) ](https://bintray.com/soulwolf/maven/ratiolayout/_latestVersion)\nThis is a specified proportion to the size of the Layout or View support library, with which you can easily set a fixed ratio of the size of the Layout or View, internal adaptive size calculation, completely abandon the code to calculate the size! If you have any questions in the course or suggestions, please send an e-mail to the following e-mail, thank you!\n\nFor more information please see \u003ca href='http://amphiaraus.org/Android-RatioLayout'\u003ethe website\u003c/a\u003e\n\n## Screenshots\n\n![Sample](https://raw.githubusercontent.com/amphiaraus/Android-RatioLayout/master/Screenshots/sample-1.jpg)\n![Sample](https://raw.githubusercontent.com/amphiaraus/Android-RatioLayout/master/Screenshots/sample-2.jpg)\n\n\n## Android-RatioLayout with xml code\n```xml\n\u003cnet.soulwolf.widget.ratiolayout.widget.RatioFrameLayout\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:layout_width=\"match_parent\"\n    app:datumRatio=\"datumWidth\"\n    app:widthRatio=\"16.0\"\n    app:heightRatio=\"9.0\"\n    android:layout_height=\"wrap_content\"\u003e\n\n    \u003cnet.soulwolf.widget.ratiolayout.widget.RatioImageView\n        android:id=\"@+id/image2\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        app:datumRatio=\"datumWidth\"\n        app:widthRatio=\"16.0\"\n        app:heightRatio=\"7.0\"\n        android:scaleType=\"centerCrop\"/\u003e\n\n    \u003cnet.soulwolf.widget.ratiolayout.widget.RatioTextView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:textSize=\"25sp\"\n        android:textStyle=\"bold\"\n        android:gravity=\"center\"\n        app:datumRatio=\"datumWidth\"\n        app:widthRatio=\"16.0\"\n        android:background=\"@color/sample_text\"\n        app:heightRatio=\"7.0\"\n        android:text=\"RatioImageView/RatioTextView:16*7\"\n        android:textColor=\"@android:color/white\"/\u003e\n\n\u003c/net.soulwolf.widget.ratiolayout.widget.RatioFrameLayout\u003e\n\n\u003cLinearLayout\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    android:layout_marginTop=\"8dp\"\n    android:orientation=\"horizontal\"\u003e\n\n    \u003cnet.soulwolf.widget.ratiolayout.widget.RatioTextView\n        android:layout_width=\"0dp\"\n        android:layout_height=\"wrap_content\"\n        android:layout_weight=\"1\"\n        android:background=\"@color/sample_primary\"\n        android:gravity=\"center\"\n        android:text=\"Square\"\n        android:textColor=\"@android:color/white\"\n        android:textSize=\"20sp\"\n        android:textStyle=\"bold\"\n        app:layoutSquare=\"true\"/\u003e\n\n    \u003cnet.soulwolf.widget.ratiolayout.widget.RatioView\n        android:layout_width=\"15dp\"\n        android:layout_height=\"wrap_content\"\n        app:heightRatio=\"1\"\n        app:widthRatio=\"1\"/\u003e\n\n    \u003cnet.soulwolf.widget.ratiolayout.widget.RatioTextView\n        android:layout_width=\"0dp\"\n        android:layout_height=\"wrap_content\"\n        android:layout_weight=\"1\"\n        android:background=\"@color/sample_primary\"\n        android:gravity=\"center\"\n        android:text=\"AspectRatio:1.0\"\n        android:textColor=\"@android:color/white\"\n        android:textSize=\"20sp\"\n        android:textStyle=\"bold\"\n        app:layoutAspectRatio=\"1\"/\u003e\n\n\u003c/LinearLayout\u003e\n\n\u003cnet.soulwolf.widget.ratiolayout.widget.RatioRelativeLayout\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:layout_width=\"match_parent\"\n    app:datumRatio=\"datumWidth\"\n    app:widthRatio=\"15.0\"\n    app:layout_marginTop=\"8dp\"\n    app:heightRatio=\"10.0\"\n    app:layout_height=\"wrap_content\"/\u003e\n\t\t\n```\n## Android-RatioLayout with java code\n```java\nRatioFrameLayout ratioFrameLayout = new RatioFrameLayout(context);\nratioFrameLayout.setRatio(datumRatio,widthRatio,heightRatio);\nratioFrameLayout.setSquare(square);\nratioFrameLayout.setAspectRatio(aspectRatio);\n```\n\n## Attr params  info\n\n\u003ctable\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003cem\u003eattrName\u003c/em\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\u003cem\u003eExplanation\u003c/em\u003e\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003edatumRatio\u003c/td\u003e\n\t\t\t\u003ctd\u003eThis parameter indicates the ratio is calculated based on Width Or Height! Default auto \u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003ewidthRatio\u003c/td\u003e\n\t\t\t\u003ctd\u003eThis parameter indicates the proportion of the size Width\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003eheightRatio\u003c/td\u003e\n\t\t\t\u003ctd\u003eThis parameter indicates the proportion of the size Height\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n            \u003ctd\u003elayoutSquare\u003c/td\u003e\n            \u003ctd\u003eThis parameter indicates the proportion of the square\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003elayoutAspectRatio\u003c/td\u003e\n            \u003ctd\u003eThis parameter indicates the proportion of the (width / height)\u003c/td\u003e\n        \u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\n## Implementing View!\n\n \u003cul\u003e\n   \t\u003cli\u003e\u003ca href='javascript:'\u003eRatioAbsoluteLayout\u003c/a\u003e\u003c/li\u003e\n   \t\u003cli\u003e\u003ca href='javascript:'\u003eRatioLinearLayout\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioButton\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioCheckBox\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioCheckedTextView\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioEditText\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioFrameLayout\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioGridLayout\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioImageButton\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioImageView\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioProgressBar\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioRadioButton\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioRadioGroup\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioRelativeLayout\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioSpace\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioTableLayout\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioTextView\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioGridView\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioListView\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioRecyclerView\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href='javascript:'\u003eRatioCardView\u003c/a\u003e\u003c/li\u003e\n \u003c/ul\u003e\n\n## Custom\n```java\npublic class RatioFrameLayout extends FrameLayout implements RatioMeasureDelegate {\n\n    private RatioLayoutDelegate mRatioLayoutDelegate;\n\n\n    public RatioFrameLayout(Context context) {\n        super(context);\n    }\n\n    public RatioFrameLayout(Context context, AttributeSet attrs) {\n        super(context, attrs);\n        mRatioLayoutDelegate = RatioLayoutDelegate.obtain(this, attrs);\n    }\n\n    public RatioFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {\n        super(context, attrs, defStyleAttr);\n        mRatioLayoutDelegate = RatioLayoutDelegate.obtain(this, attrs, defStyleAttr);\n    }\n\n    @TargetApi(Build.VERSION_CODES.LOLLIPOP)\n    public RatioFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {\n        super(context, attrs, defStyleAttr, defStyleRes);\n        mRatioLayoutDelegate = RatioLayoutDelegate.obtain(this, attrs, defStyleAttr, defStyleRes);\n    }\n\n    @Override\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n        if (mRatioLayoutDelegate != null) {\n            mRatioLayoutDelegate.update(widthMeasureSpec, heightMeasureSpec);\n            widthMeasureSpec = mRatioLayoutDelegate.getWidthMeasureSpec();\n            heightMeasureSpec = mRatioLayoutDelegate.getHeightMeasureSpec();\n        }\n        super.onMeasure(widthMeasureSpec, heightMeasureSpec);\n    }\n\n    @Override\n    public void setRatio(RatioDatumMode mode, float datumWidth, float datumHeight) {\n        if (mRatioLayoutDelegate != null) {\n            mRatioLayoutDelegate.setRatio(mode, datumWidth, datumHeight);\n        }\n    }\n\n    @Override\n    public void setSquare(boolean square) {\n        if (mRatioLayoutDelegate != null) {\n            mRatioLayoutDelegate.setSquare(square);\n        }\n    }\n\n    @Override\n    public void setAspectRatio(float aspectRatio) {\n        if (mRatioLayoutDelegate != null) {\n            mRatioLayoutDelegate.setAspectRatio(aspectRatio);\n        }\n    }\n}\n```\n\n## Maven\n\t\u003cdependency\u003e\n      \u003cgroupId\u003enet.soulwolf.widget\u003c/groupId\u003e\n      \u003cartifactId\u003eratiolayout\u003c/artifactId\u003e\n      \u003cversion\u003e2.1.0\u003c/version\u003e\n      \u003ctype\u003epom\u003c/type\u003e\n    \u003c/dependency\u003e\n## Gradle\n\tallprojects {\n       repositories {\n          jcenter()\n       }\n\t}\n\t\n\tcompile 'net.soulwolf.widget:ratiolayout:2.1.0'\n\n## Developed by\n  Amphiaraus - \u003ca href='javascript:'\u003eamphiarause@gmail.com\u003c/a\u003e\n\n## License\n\tCopyright 2015 The Android Open Source Project for Android-RatioLayout\n\t\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\t    http://www.apache.org/licenses/LICENSE-2.0\n\t\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n\t\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapleqin%2FAndroid-RatioLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmapleqin%2FAndroid-RatioLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapleqin%2FAndroid-RatioLayout/lists"}