一、Android的界面UI元素

(1)视图组件(View)

  在Android当中View类是最基本的一个UI类,基本上所有的高级UI组件都继承View类而实现的,常用的有TextView,Button,List,EditText,RadioButton,Checkbox等都是View类。

  一个视图(View)在屏幕上占据了一块矩形区域,它负责渲染这块矩形区域(如改变背景色),也可以处理这块矩形区域发生的事件(如用户点击了这块区域),并且可以设置这块区域是否可见,是否可以获取焦点等。

(2)视图容器组件(Viewgroup)

  一个Viewgroup对象是一个Android.view.Viewgroup的实例,Viewgroup的作用就是View的容器,它负责对添加进Viewgroup的这些View进行布局。一个Viewgroup也可以加入到另外一个Viewgroup里。

(3)布局组件(Layout)

  Viewgroup的实现类比较多,最常用的有两类,一个是LinearLayout,它可以进行水平布局或竖直布局。在xml中常用的代码如下

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"><ProgressBar android:id="@+id/progress_bar"
     style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content"
     android:layout_height="wrap_content"/></LinearLayout>

  RelativeLayout是一个相对布局类,负责相对布局。