Monday, January 14, 2013

7. XML format for EditText and EditText parameters

  1. EditText Format in XML

    <EditText
                    android:id="@+id/editText1"

   <requestFocus />
    </EditText>

 2.Important EditText Parameters


        android:layout_width="wrap_content" 
         (restrict the width of the layout to the content width, eg. width of text)
        android:layout_width="match_parent" 
        (extend the width to the parent width.eg.fill the screen width)
        android:layout_height="wrap_content"  
        (restrict the height of the layout to the content height. eg. height of text)
        android:layout_height="match_parent" 
        (extend the height to the parent height.eg. fill the screen height)

       
        android:hint="@string/hint1"
      (Display a text when the field is empty. Will automatically disappear when a text is entered. The hint  text is storedin a string called " hint1", string is to be specified in the "strings.xml' file in the
folder named "values as follows)
        <string name="hint1">your text here</string>
   
        android:textColor="@color/white" 
    (Apply the color stored in the string"white". string is to be specified in the "strings.xml in  the folder named   "values" as follows)
        <color name="white">#FFFFFF</color>

        android:textSize="15sp"
        (Display the size of the text in 15 scaled pixels, device independent)

        android:textStyle="bold"
         (Display the text as bold)

       android:typeface="serif"
         (Display the text in "serif" font)

        android:height="15sp"
        (Fix the height of the textview to 15sp)

        android:gravity="1"
        android:gravity="2"
    (If the gravity of item1 is "1" and of item2 is "2" both will occupy the area in the ratio 1:2, default gravity=0)

        android:gravity="center"
       (Display the text in the center of textview)

       
        android:layout_marginLeft="20dp"
       (A space of 20dp is kept on the left side)

        android:layout_marginRight="20dp"
        (A space of 20dp is kept on the right side)
       android:layout_marginBottom="20dp"
       (A space of 20dp is kept on the bottom)
       android:layout_marginBottom="20dp"
       (A space of 20dp is kept on the top)

        android:layout_alignParentTop="true"
        (Position the EditText at top of the parent. eg. top of screen)

        android:layout_alignParentBottom="true"
        (Position the EditText at bottom of the parent. eg. bottom of screen)

        android:layout_alignParentRight="true"
       (Position the EditText at right side of the parent. eg. right side of screen)

        android:layout_alignParentLeft="true"
       (Position the EditText at left side of the parent. eg. left side of screen)
      
        android:layout_alignBottom="@+id/button1"
        (Align the bottom of the EditText to button1)

        android:layout_toRightOf="@+id/button1"
        (Align the  EditText to the right of button1)

        android:layout_toLeftOf="@+id/button1"
        (Align the EditText to the left of button1)

        android:layout_centerHorizontal="true"
        (Position the EditText in Center Horizontal)

        android:layout_centerVertical="true"
       (Position the EditText in Center Vertical)

1 comment:

  1. The Original Forex Trading System: roboforex login Is The Original Forex Trading System. It Is 100% Automated And Provides An Easy-to-follow Trading System. You Get Access To Real-time Signals, Proven Methods, And A Money-back Guarantee.

    ReplyDelete

Please give your valuable comments so as to know whether this blog is useful to you.You can also write helpful Android Development Syntax or Shortcuts or Tips.