Download presentation
Presentation is loading. Please wait.
Published byMyles O’Neal’ Modified over 9 years ago
1
FramesLayout & Image View Pages 20-21
2
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.
3
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
4
FrameLayout & Image View
5
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
7
Final Result
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.