Những control cơ bản cần phải biết trong lập trình android.

Xin chào các Bạn tiếp tục list bài hướng dẫn lập trình android của mình thì bài này. Mình sẽ giới thiệu các Bạn những control cơ bản cần phải nắm rõ để áp dụng vào những ứng dụng của các Bạn sau này. Với các control này thì nếu Bạn nào đã học môn "Môi trường và công cụ lập trình " hay " Lập trình windows form" thì các Bạn có thể liên tưởng để dễ hiểu hơn vì trong android chỉ thay đổi tên gọi thôi và có những control khác. ví dụ trong windows form để hiện thị 1 text là label thì android là TextViews.... Dưới đây mình sẽ list các Control cơ Bản mà các Bạn cần phải nắm rõ. Và với bài này mình sẽ chia làm 2 phần chính đó là LayoutWidget

Phần 1: Các Layout cần phải nắm rõ.

Layout là phần để các Bạn thiết kế giao diện cho ứng dụng của Bạn. Có thể liên tưởng nó giống như vẻ bề ngoài của các Bạn. Và trong 1 layout có thể chứa rất nhiều layout hoặc widget khác nhau. dưới đây là 4 layout các Bạn cần phải nắm rõ.
  1. RelativeLayout
  2. LinearLayout Ở Layout này có 2 loại các Bạn cần phải biết đó là: LinearLayout( Horizontal) : Với layout này các widget của Bạn bỏ vào sẽ sếp theo kiểu dàn hàng ngang ra. LinearLayout (Vertical) : Với layout này các widget của Bạn bỏ vào sẽ sếp theo kiểu bậc thang từ trên xuống dưới.
  3. TableLayout
  4. FrameLayout
Để sử dụng và kết nối các layout này với file java các Bạn phải khai báo file java trong "AndroidManifest.xml" và trong hàm onCreate các Bạn setContentView như sau :
  • setContentView(R.layout.activity_main);

Phần 2: Các Widget cơ bản cần phải biết trong lập trình android.

  1. TextView<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Medium Text" android:id="@+id/textView2" />
  2. Button<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" />
  3. RadioButton <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New RadioButton" android:id="@+id/radioButton" />
  4. ListView <ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/listView" />
  5. GridView <GridView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/gridView" />
  6. CheckBox <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New CheckBox" android:id="@+id/checkBox" />
  7. ImageView<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView" />
  8. ImageButton <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageButton" />
  9. Plain Text (Edit Text) <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/editText" />
  10. WebView <WebView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/webView" />
  11. Spinner <Spinner android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/spinner" />
  12. VideoView <VideoView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/videoView" />
Vậy là đã xong bài viết giới thiệu những điều cơ bản về layout và các Widget cơ bản trong android. Với Layout và Widget sẽ giúp Bạn thiết kế được một giao diện hoàn hảo cho ứng dụng của mình. Cảm ơn các Bạn đã ghé thăm blog của mình. Một lời cảm ơn hoặc like or share của các Bạn sẽ là động lực để mình viết tiếp.

Comments

Popular posts from this blog

Cách custom bo tròn cạnh imageView trong android

Tối ưu ListView với Viewholder trong lập trình ứng dụng android.

Lập trình android: Hiệu ứng khi xóa một item ra khỏi listview