Saturday 9 June 2012

AbsoluteLayout




AbsoluteLayout is based on the simple idea of placing each control at an absolute position. You specify the exact x and y coordinates on the screen for each control. This is not recommended for most UI development (in fact AbsoluteLayout is currently deprecated) since absolutely positioning every element on the screen makes an inflexible UI that is much more difficult to maintain.  Consider what happens if a control needs to be added to the UI. You would have to change the position of every single element that is shifted by the new control.



XML code for above UI ....

xml version="1.0" encoding="utf-8">
<?
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/AbsoluteLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="48dp"
android:layout_y="199dp"
android:ems="10" android:hint="Username" android:textColorHint="#ff0000"/>
 
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="48dp"
android:layout_y="259dp"
android:ems="10"
android:hint="password"
android:inputType="textPassword" android:textColorHint="#ff0000"/>
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="2dp"
android:layout_y="364dp"
android:text="submit" />
<TextView
android:id="@+id/textView1"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_x="98dp"
android:layout_y="125dp"
android:text="Sign in"
android:textAppearance="?android:attr/textAppearanceLarge" />
>
 
</AbsoluteLayout>

0 comments:

Post a Comment

Blogroll

Blogger templates

About