Android Graphic and Animation 1

Download sdk มาไว้ในเครื่อง

C:\Users\Lenovo\Downloads\Compressed\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk

เริ่มเขียนโปรแกรม java สร้าง Project ด้วยโปรแกรม  eclipe

Picture 2014-03-01 11_22_44 Picture 2014-03-01 11_23_22  Picture 2014-03-01 11_24_27 Picture 2014-03-01 11_24_47

MainActivity.java
package petcharaporn.p.myapp1;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {
@Override
  protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
}

Picture 2014-03-01 11_25_11

เอา  Button มาวางตามตำแหน่งที่ต้องการในหน้าจอโทรศัพท์Picture 2014-03-01 11_26_06 Picture 2014-03-01 11_26_18

กดแป้นตัวเลข 7 จะสลับหน้าจอเป็นแนวขวางPicture 2014-03-01 11_26_34Activity_Main.java

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#AAAAAA" (เปลี่ยนหน้าจอเป็นสีเทา)
tools:context=".MainActivity" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

<Button
android:id="@+id/button1"
style="@android:style/Widget.Holo.Button.Inset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:text="Button" />
</RelativeLayout>

 

 

 

Bookmark the permalink.

Comments are closed.