Android Learning Note: Framelayout Layout Basics

Source: Internet
Author: User

The framelayout layout is characterized by: all view components placed in the layout are stacked hierarchically in the upper-left corner of the screen, followed by a view component that overrides the previous one.

Of course, the component itself can control its own internal layout.

A common scenario is that you can animate by placing multiple picture views on the framelayout.

Let's look at a simple example:

1. Create an App

2, create the main activity, the activity uses the Framelayout layout, the contents of the layout file are as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<framelayout xmlns:android= "Http://schemas.android.com/apk/res/android"

................

>

<button
Android:id= "@+id/button1"
Android:layout_width= "400px"
android:layout_height= "400px"
Android:background= "#888888"
/>

<button
Android:id= "@+id/button2"
Android:layout_width= "300px"
android:layout_height= "300px"
Android:background= "#555555"
/>

<button
Android:id= "@+id/button3"
Android:layout_width= "200px"
android:layout_height= "200px"
Android:background= "#222222"
/>

</FrameLayout>

3, run the app, you can see the corresponding effect. If you are using Eclipse development, you can see the same effect by looking directly at the graphical view of the layout file, as follows:

As you can see, the first button (the largest size) is on the lowest level, the 2nd button is above it, and the 3rd button is on top.

On the basis of this most basic feature, combined with the view of the hidden or transparent background and other properties, you can achieve a variety of special display methods.

Note: Do not confuse framelayout with fragment, which is completely irrelevant, the former is a layout of the view, the latter is a view component.

Android Learning Note: Framelayout Layout Basics

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.