Android framelayout Sub View Center (left center, right center), etc.

Source: Internet
Author: User

Android layout framelayout default is to put the layout of sub-view in the upper left corner, but can be set by the child view:

Android:layout_gravity

This parameter controls the layout position of the sub-view, implements the various sub-view layout positions of the framelayout, such as center left, center right, center, and so on, the key points in the android:layout_gravity parameter settings in combination with "center", "left", " Right "and so on, now give the XML code instance layout:

<framelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" match_parent "> <Text View android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:background= "@an        Droid:color/black "android:text=" upper left Corner "android:textcolor=" @android: Color/white "/> <textview Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_gravity= "Left|center "Android:background=" @android: Color/black "android:text=" left Center "android:textcolor=" @android: Color/whit E "/> <textview android:layout_width=" wrap_content "android:layout_height=" Wrap_content "and Roid:layout_gravity= "Right" android:background= "@android: Color/black" android:text= "Android:text Color= "@android: Color/white"/> <textviEW android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:layout_gravity= "R Ight|center "android:background=" @android: Color/black "android:text=" right Center "android:textcolor=" @android         : Color/white "/> <textview android:layout_width=" wrap_content "android:layout_height=" Wrap_content " android:layout_gravity= "center" android:background= "@android: Color/black" android:text= "center" a Ndroid:textcolor= "@android: Color/white"/></framelayout>

Operation Result:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. Reprint Please specify source: Http://blog.csdn.net/zhangphil

Android framelayout Sub View Center (left center, right center), etc.

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.