Category: C #, Android, VS2015;
Date Created: 2016-02-11 I. INTRODUCTION
Frame layout is an effective means of displaying multiple levels of graphs. For example, the 3rd chapter introduces the Baidu map is the use of frame layout to achieve, it will be divided into 22 levels of the layer is cached to the specified folder, the program according to the user to the map magnification, automatically determine which level should be the topmost layer. In addition, the map overlay function is also used to achieve this.
The frame layout is characterized by that all elements are placed from the upper left corner of the container, the first element being added is placed at the bottom, and the last added element is placed at the top level. By default, the elements of the previous layer overwrite the next layer of elements, unless the different layer elements are not the same size (their effect is partially covered), or the elements in the top layer are transparent.
Specifically, for elements with an opacity of 1 (the range 0.0~1.0,1 is completely opaque), it can be further subdivided into:
(1) if the lower and upper elements have the same width and height, the upper element will completely overwrite the underlying element.
(2) If the underlying element is large and the upper element is small, the upper element only partially covers the underlying element. Second, example-demo05framelayout
This example shows a simple illustration of 3 layers:
No. 0 Floor: img1.jpg
1th Floor: img2.jpg
2nd Floor: Img3.jpg
Each time you click the next Layer button, the layer is reduced by 1 and the corresponding layer's diagram is displayed. When the No. 0 layer is reduced, it becomes the 2nd layer and loops in turn.
Note: The example is only intended to demonstrate a layer overlay (visible by default, but only at the top level), and the example does not deal with the problem of how to cache the picture.
1. Operation
2. Add Demo05framelayout.axml File
Add the file under the Resources/layout folder.
<?XML version= "1.0" encoding= "Utf-8"?><Framelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"> <ImageViewAndroid:id= "@+id/image1"android:src= "@drawable/sample_2"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent" /> <ImageViewAndroid:id= "@+id/image2"android:src= "@drawable/sample_4"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent" /> <ImageViewAndroid:id= "@+id/image3"android:src= "@drawable/sample_6"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent" /> <ButtonAndroid:id= "@+id/btnnext"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Next Layer"android:layout_gravity= "Center_horizontal" /></Framelayout>
3. Add Demo05FrameLayout.cs File
Add the file under the Srcdemos folder.
usingSystem.Collections.Generic;usingAndroid.app;usingAndroid.os;usingandroid.views;usingAndroid.widget;namespaceCh07demos. srcdemos{[Activity (Label="Demo05framelayout")] Public classdemo05framelayout:activity {List<ImageView> images =NewList<imageview>(); intCurrent ; protected Override voidOnCreate (Bundle savedinstancestate) {Base. OnCreate (savedinstancestate); Setcontentview (Resource.Layout.Demo05FrameLayout); Images. ADD (Findviewbyid<ImageView>(Resource.Id.image1)); Images. ADD (Findviewbyid<ImageView>(Resource.Id.image2)); Images. ADD (Findviewbyid<ImageView>(Resource.Id.image3)); Current= images. Count-1; Findviewbyid<Button> (Resource.Id.btnNext). Click + =Delegate{images[current]. Visibility=viewstates.invisible; Current--; if(Current <0) Current = images. Count-1; Images[current]. Visibility=viewstates.visible; }; } }}
"Android" chapter 7th (7) Framelayout (frame layout)