這篇文章將為大家詳細(xì)講解有關(guān)Android使用Recyclerview實(shí)現(xiàn)圖片輪播效果的方法,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
效果圖:
思路:
1.準(zhǔn)備m張圖片
1.使用Recyclerview實(shí)現(xiàn),返回?zé)o數(shù)個(gè)(實(shí)際Interge.MAXVALUE)item,第n個(gè)item顯示第n%m張圖片
3.使用recyclerview.scrollBy 每個(gè)一段時(shí)間水平滾動(dòng)一段距離
4.通過layoutManager.findFirstVisibleItemPosition()獲取當(dāng)前顯示的第一個(gè)View是第幾個(gè)item,上面的ImageView顯示對(duì)應(yīng)de圖片
實(shí)現(xiàn)代碼:
XML文件
1.activity布局文件activity_recy.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:layout_width="300dp" android:layout_height="350dp" android:layout_gravity="center_horizontal" android:id="@+id/img" android:src="@drawable/p5" android:scaleType="fitXY" /> <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="150dp" android:layout_marginTop="10dp" android:id="@+id/recyclerview" ></android.support.v7.widget.RecyclerView> </LinearLayout>
網(wǎng)站題目:Android使用Recyclerview實(shí)現(xiàn)圖片輪播效果的方法-創(chuàng)新互聯(lián)
文章源于:http://www.chinadenli.net/article26/dhsojg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、關(guān)鍵詞優(yōu)化、標(biāo)簽優(yōu)化、微信公眾號(hào)、虛擬主機(jī)、網(wǎng)頁設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容