Gallery can display a series of pictures, and can slide horizontally. The following shows how to use Gallery to display a series of pictures.
1. Create a project, Gallery.
2. Code in the Main.xml.
<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android=
"http://schemas.android.com/apk/" Res/android "
android:layout_width=" fill_parent "
android:layout_height=" fill_parent "
android:o" rientation= "vertical" >
<textview
android:layout_width= "Fill_parent"
Wrap_content "
android:text=" Images of San Francisco "/> <gallery android:id="
@+id/gallery1 "
android:layout_width= "fill_parent"
android:layout_height= "wrap_content"/>
<imageview
android:id= "@+id/image1"
android:layout_width= "320DP"
android:layout_height= "250DP"
Android:scaletype= "Fitxy"/>
</LinearLayout>
3. Create a new file under the Res/values folder, Attrs.xml.
4. Code in the Attrs.xml.
<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<declare-styleable name= "Gallery1" >
<attr name= "Android:galleryitembackground"/>
</declare-styleable>
</resources>
5. Prepare some pictures. Put these pictures underneath the res/drawable-mdpi.