Wednesday, 13 February 2013

Using Frame Layout in Android


Framelayout in Android:


"The FrameLayout is a placeholder on screen that you can use to display a single view. Views that you
add to a FrameLayout are always anchored to the top left of the layout. Consider the following content
in main.xml:"


<?xml version=”1.0” encoding=”utf-8”?>
   <RelativeLayout
       android:id=”@+id/RLayout”
       android:layout_width=”fill_parent”
       android:layout_height=”fill_parent”
       xmlns:android=”http://schemas.android.com/apk/res/android”
   >
  <TextView
     android:id=”@+id/lblComments”
   android:layout_width=”wrap_content”
   android:layout_height=”wrap_content”
   android:text=”This is my lovely dog, Ookii”
   android:layout_alignParentTop=”true”
   android:layout_alignParentLeft=”true”
 />
  <FrameLayout
      android:layout_width=”wrap_content”
      android:layout_height=”wrap_content”
      android:layout_alignLeft=”@+id/lblComments”
      android:layout_below=”@+id/lblComments”
      android:layout_centerHorizontal=”true”
    >
   <ImageView
       android:src = “@drawable/ookii”
       android:layout_width=”wrap_content”
       android:layout_height=”wrap_content”
   />
  </FrameLayout>
</RelativeLayout>
Here, you have a FrameLayout within a RelativeLayout. Within the FrameLayout, you embed an
ImageView.

No comments:

Post a Comment