Recommended Android Layout percent frame

Source: Internet
Author: User

Githup:https://github.com/juliengenoud/android-percent-support-lib-sample

Here's how to use it:

Android Percent Support Lib Sample

I made a sample of the new percent support library.
You can check official Docs reference here and here.
This library provide percentage based layouts, horizontal and vertical at the same time.

Simple result

Complex result

How to use:

Just add percent support library to your project

Dependencies {    'com.android.support:percent:25.3.0'}

# # #Supported Layouts:

# # #PercentRelativeLayout

<Android.support.percent.PercentRelativeLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent">        <ViewAndroid:id= "@+id/top_left"Android:layout_width= "0DP"Android:layout_height= "0DP"Android:layout_alignparenttop= "true"Android:background= "#ff44aacc"app:layout_heightpercent= "20%"app:layout_widthpercent= "70%" />    <ViewAndroid:id= "@+id/top_right"Android:layout_width= "0DP"Android:layout_height= "0DP"Android:layout_alignparenttop= "true"Android:layout_torightof= "@+id/top_left"Android:background= "#ffe40000"app:layout_heightpercent= "20%"app:layout_widthpercent= "30%" />    <ViewAndroid:id= "@+id/bottom"Android:layout_width= "Match_parent"Android:layout_height= "0DP"Android:layout_below= "@+id/top_left"Android:background= "#ff00ff22"app:layout_heightpercent= "80%" /></Android.support.percent.PercentRelativeLayout>

# # #PercentLinearLayout

<Com.juliengenoud.percentsamples.PercentLinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical">     <ViewAndroid:layout_width= "0DP"Android:layout_height= "0DP"Android:background= "#ff44aacc"app:layout_heightpercent= "10%"app:layout_widthpercent= "60%"/>    <ViewAndroid:layout_width= "0DP"Android:layout_height= "0DP"Android:background= "#ff4400cc"app:layout_heightpercent= "10%"app:layout_widthpercent= "70%"/></Com.juliengenoud.percentsamples.PercentLinearLayout>

# # #PercentFrameLayout

< android.support.percent.PercentFrameLayout     xmlns:android = "Http://schemas.android.com/apk/res/android"     xmlns:app= "Http://schemas.android.com/apk/res-auto"    android:layout_width = "Match_parent"     android:layout_height= "match_parent">        <!--  -</android.support.percent.PercentFrameLayout> 

Simple and clear.

Recommended Android layout percent frame

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.