Android percentrelativelayout support percentage to set the control's width height

Source: Internet
Author: User

Android eventually officially supports setting the width of the control by a percentage.
Let's start by looking at the effect:

look at the layout:

Percentrelativelayout

<android.support.percent.percentrelativelayout 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 "> <view android:id=" @+id/top_left "android:layout_width=" 0DP "android:layou t_height= "0DP" android:layout_alignparenttop= "true" android:background= "#ff44aacc" App:layout_heig Htpercent= "20%" app:layout_widthpercent= "70%"/> <view android:id= "@+id/top_right" Andro Id:layout_width= "0DP" android:layout_height= "0DP" android:layout_alignparenttop= "true" Android:lay out_torightof= "@+id/top_left" android:background= "#ffe40000" app:layout_heightpercent= "20%" App:la         yout_widthpercent= "30%"/> <view android: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>


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" >         <!--... XML CODE--</android.support.percent.PercentFrameLayout>


Stylable:

    • Heightpercent
    • Widthpercent
    • Marginbottompercent
    • Marginendpercent
    • Marginleftpercent
    • Marginpercent
    • Marginrightpercent
    • Marginstartpercent
    • Margintoppercent

Support:

    • Android SDK V22
    • Android Build Tools v22.0.1
    • Android Percent Support Repository v22.2.0
    • Android Support V4 Repository v22.2.0
according to the manifest Minsdk is V7 (Android 2.1)


GitHub Address: https://github.com/JulienGenoud/-support-lib-samplewebsite Description: https://juliengenoud.github.io/a ... support-lib-sample/

Android percentrelativelayout support percentage to set the control's width height

Related Article

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.