1、ProgressBar、SeekBar与RatingBar控件
ProgressBar控件,也就是我们通常的进度条控件,可以显示加载的进度等。SeekBar控件,滑块控件,可以根据用户的需要动态为赋值。本例子就是拖动SeekBar,让进度条实时显示拖动的进度。RatingBar控件,星条控件,我们经常见到的打分控件,五颗星星。下面是main.xml页面的代码。我们声明了几个控件。
1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:paddingBottom="@dimen/activity_vertical_margin" 6 android:paddingLeft="@dimen/activity_horizontal_margin" 7 android:paddingRight="@dimen/activity_horizontal_margin" 8 android:paddingTop="@dimen/activity_vertical_margin" 9 tools:context=".MainActivity" > 10 11 <TextView 12 android:id="@+id/textView1" 13 android:layout_width="wrap_content" 14 android:layout_height="wrap_content" 15 android:text="@string/hello_world" /> 16 17 <ProgressBar 18 android:id="@+id/progressBar1" 19 android:layout_width="fill_parent" 20 android:layout_height="wrap_content" 21 android:layout_alignParentLeft="true" 22 android:layout_below="@+id/textView1" 23 android:layout_marginTop="68dp" 24 android:background="@drawable/color" /> 25 26 <SeekBar 27 android:id="@+id/seekBar1" 28 android:layout_width="match_parent" 29 android:layout_height="wrap_content" 30 android:layout_alignParentLeft="true" 31 android:layout_alignParentRight="true" 32 android:layout_below="@+id/progressBar1" 33 android:layout_marginTop="48dp" /> 34 35 <RatingBar 36 android:id="@+id/ratingBar1" 37 android:layout_width="wrap_content" 38 android:layout_height="wrap_content" 39 android:layout_alignLeft="@+id/seekBar1" 40 android:layout_below="@+id/seekBar1" 41 android:layout_marginTop="68dp" /> 42 43 <ProgressBar 44 android:id="@+id/progressBar2" 45 style="?android:attr/progressBarStyleHorizontal" 46 android:layout_width="fill_parent" 47 android:layout_height="wrap_content" 48 android:layout_alignParentRight="true" 49 android:layout_below="@+id/ratingBar1" /> 50 51 </RelativeLayout>