類型:源碼相關大小:23.6M語言:中文 評分:9.1
標簽:
立即下載
第 4 頁 實現循環顯示圖像的Gallery組件
實現循環顯示圖像的Gallery組件
在本節將組出與循環顯示圖像相關的ImageAdapter類的完整代碼。讀者可以從中看到上一節介紹的兩點改進。為了使界面看上去更豐滿,本例還在單擊某一個Gallery組件中的圖像時在下方顯示一個放大的圖像(使用ImageSwitcher組件)。本例的顯示效果如圖3所示。當不斷向后移動圖像時,圖像可不斷顯示,讀者可以自己運行本例來體驗一下。
在main.xml文件中定義的Gallery和ImageSwitcher組件的代碼如下:
代碼
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_height="wrap_content" android:layout_marginTop="30dp" />
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginTop="30dp" />