Вы находитесь на странице: 1из 10

Android development

A N D R O I D
L A Y O U T S


Frame Layout
FrameLayout is designed to display a single
item at a time.
We can have multiple elements within a
FrameLayout but each element will be
positioned based on the top left of the screen.
Elements that overlap will be displayed
overlapping.
Frame Layout Example
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome To android"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Good Evening"
/>
</FrameLayout>
The Output
The Output(right)
The Output(center)
The Output(center_vertical)
The Output(center_vertical|right)
Frame Layout
FrameLayout can become more useful when
elements are hidden and displayed
programmatically.
We can call setVisibility() from the code to
hide or display the elements.
This method belongs to View class.
The prototype of the method is :
public void setVisibility(int)
Frame Layout
The three available visibility values are :

1 VISIBLE
2 INVISIBLE(does not display, but still takes up
space in the layout)
3 GONE (does not display, and does not take
space in the layout).

Вам также может понравиться