Pages

Saturday, September 8, 2012

Android Example of frame layout


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/day">

<FrameLayout
android:layout_width="match_parent"
  android:layout_height="match_parent"
>
<ImageView
        android:id="@+id/ImageView01"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:src="@drawable/pinkrose"
     
     
     >
     </ImageView>
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         android:textColor="#ff00ff00"
        android:textSize="40dp"
        android:text="@string/top_text" />
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/bottom_text"
        android:layout_gravity="bottom"
        android:gravity="right"
        android:textColor="#ff00ff00"
        android:textSize="50dp" />

</FrameLayout>
</LinearLayout>

Monday, May 28, 2012

Android make a register page


 create your xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView android:text="Register Page"
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
</TextView>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout


android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="username"
    />


<EditText android:id="@+id/editText1"
android:layout_width="match_parent"
android:text=""
android:gravity="center"
android:layout_gravity="center_horizontal"
 android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="20dp" android:layout_marginBottom="20dp">
 </EditText>
 <TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="password"
    />
<EditText android:id="@+id/editText2"
 android:layout_width="match_parent"
  android:text="EditText"
   android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="20dp">
   </EditText>
   <TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="re-enter password"
    />
<EditText android:id="@+id/editText3"
android:layout_width="match_parent"
android:text="EditText"
 android:layout_height="wrap_content" android:layout_marginTop="20dp" android:layout_marginRight="20dp" android:layout_marginLeft="20dp" android:layout_marginBottom="20dp">
 </EditText>
 <TextView
 android:text="gender"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"/>
 <RadioGroup
 android:tag="gender"
 android:orientation="vertical"
 android:gravity="left"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">

 <RadioButton
 android:text="male"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:id="@+id/male_radio"
 />

 <RadioButton
 android:text="female"
  android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:id="@+id/female_radio"
 />


 </RadioGroup>
  <TextView
      android:id="@+id/txtRadio"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="nothing"
    />
 <TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="choose hobby"
    />
<CheckBox android:text="singing"
 android:id="@+id/checkBox1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  </CheckBox>
<CheckBox android:text="playing"
 android:id="@+id/checkBox2"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  </CheckBox>
<CheckBox android:text="reading"
 android:id="@+id/checkBox3"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
 </CheckBox>

<Button android:text="submit"
 android:id="@+id/button1"
  android:layout_width="wrap_content"
   android:layout_height="wrap_content">
   </Button>
   </LinearLayout>
</ScrollView>
</LinearLayout>





 now paste this code in your activity class.
and don't forget to change your package name and activity name.

package yourpackage.name;

import android.app.Activity;
import android.os.Bundle;


public class Register extends Activity {
 
  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
}
}

first android program example


 Your First Program

first create an xml file with name main .xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView android:text="hello to android"
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
</TextView>
</LinearLayout>


paste this code in your first activity class

package yourpackage.name;

import android.app.Activity;
import android.os.Bundle;


public class FirstActivity extends Activity {
   
  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

}
}

this is your first hello to Android program.