Download this Blogger Template by Clicking Here!

Ad 468 X 60

Share

Widgets

Thursday, December 08, 2011

Widgets

Working with Images in Android :


# We have to create a "Login Page" with table layout and having background image :



  • Create an xml file named as "login.xml" and copy and paste below code to this xml file.
  • Pick an image file and copy this in res/drawable folder.(for background)

// Source Code of  login.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
   
        <TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bgscreen">

<TableRow android:weightSum="1.0"
   android:layout_marginTop="270px">
                             <TextView
                                           android:layout_width="wrap_content"
                                           android:layout_height="wrap_content"
                                           android:text="Username "
                                           android:textColor="#0000FF"
                                           android:textSize="20dip" />
                             <EditText
                                           android:id="@+id/txt_name"
                                           android:layout_height="wrap_content"
                                           android:layout_width="fill_parent"
                                           android:layout_weight="1.0"
                                           android:hint="Enter username"></EditText>
                 </TableRow>
         
                  <TableRow android:weightSum="1.0">
                             <TextView
                                          android:layout_width="wrap_content"
                                          android:layout_height="wrap_content"
                                          android:text="Password "
                                          android:textColor="#0000FF"
                                          android:textSize="20dip" />
                            <EditText 
                                          android:id="@+id/txt_password"
                                          android:layout_height="wrap_content"
                                          android:layout_width="fill_parent"
                                          android:layout_weight="1.0"
                                          android:password="true"
                                          android:hint="Enter password">
                             </EditText>
                    </TableRow>
                      
    <TableRow android:weightSum="1.0">
      <Button
                android:id="@+id/btn_login"
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:text="Login"
                android:clickable="true"
                android:layout_marginLeft="40px">
       </Button>
       <Button 
                android:id="@+id/btn_reset"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Reset"
                android:clickable="true"
                android:layout_marginLeft="40px">
       </Button>
                     </TableRow>        
</TableLayout>
</LinearLayout>




Output :



         





SHARE THIS POST   

  • Facebook
  • Twitter
  • Myspace
  • Google Buzz
  • Reddit
  • Stumnleupon
  • Delicious
  • Digg
  • Technorati
Author: Mohammad
Mohammad is the founder of STC Network which offers Web Services and Online Business Solutions to clients around the globe. Read More →

0 comments: