7
FramesLayout & Image View Pages 20-21

FramesLayout & Image View Pages 20-21. FrameLayout is a ViewGroup that divides the screen into blocks of area each of which is supposed to holds a single

Embed Size (px)

Citation preview

Page 1: FramesLayout & Image View Pages 20-21. FrameLayout is a ViewGroup that divides the screen into blocks of area each of which is supposed to holds a single

FramesLayout & Image View

Pages20-21

Page 2: FramesLayout & Image View Pages 20-21. FrameLayout is a ViewGroup that divides the screen into blocks of area each of which is supposed to holds a single

FrameLayout • is a ViewGroup that divides the screen into

blocks of area each of which is supposed to holds a single child View. You may place multiple child Views inside a single block, then the latter ones will overlay the preceding ones. The android:layout_gravity attribute of the child View will dictate which block it will go into. Let's build a page using FrameLayout as the layout model that contains an ImageView overlaid with a TextView.

Page 3: FramesLayout & Image View Pages 20-21. FrameLayout is a ViewGroup that divides the screen into blocks of area each of which is supposed to holds a single

Creating a FrameLayout• Create a new Activity called "FrameLayout", then

follow these steps to create a UI.– Open its layout XML file "activity_frame_layout.xml"

in Design view– Delete the default RelativeLayout and TextView– Drag and drop a FrameLayout layout from the Palette

to the screen– Drag and drop an ImageView to the center of the

screen and set its src property to "@drawable/ic_launcher"

– Drag and drop a Large Text to overlay the ImageView

Page 4: FramesLayout & Image View Pages 20-21. FrameLayout is a ViewGroup that divides the screen into blocks of area each of which is supposed to holds a single

FrameLayout & Image View

Page 5: FramesLayout & Image View Pages 20-21. FrameLayout is a ViewGroup that divides the screen into blocks of area each of which is supposed to holds a single

Code for FrameLayout• Open the "activity_frame_layout.xml" in Text view,

the XML content should look like the image on the next slide.

• The code was hard coded the text for the android:text attribute of the TextView here, what a sin! But you should heed the advice from Learning Point 7.

• Try changing the value to the android:layout_gravity attribute and watch the change taking place in the Preview screen

Page 6: FramesLayout & Image View Pages 20-21. FrameLayout is a ViewGroup that divides the screen into blocks of area each of which is supposed to holds a single
Page 7: FramesLayout & Image View Pages 20-21. FrameLayout is a ViewGroup that divides the screen into blocks of area each of which is supposed to holds a single

Final Result