Android開發(fā)中使用RecyclerView怎么實現(xiàn)一個時光軸效果?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供伊金霍洛網(wǎng)站建設(shè)、伊金霍洛做網(wǎng)站、伊金霍洛網(wǎng)站設(shè)計、伊金霍洛網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、伊金霍洛企業(yè)網(wǎng)站模板建站服務(wù),十多年伊金霍洛做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。
如圖:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:overScrollMode="never" /> </RelativeLayout>
item.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="8dp" android:paddingRight="8dp" android:paddingTop="8dp"> <TextView android:id="@+id/item_timeline_time" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginRight="8dp" android:layout_marginTop="18dp" android:gravity="center_horizontal" android:padding="4dp" android:textColor="@color/colorAccent" android:textSize="16sp" android:text="2015-06-08\n09:56" /> <RelativeLayout android:id="@+id/item_timeline_icon_layout" android:layout_width="48dp" android:layout_height="48dp" android:layout_marginBottom="4dp" android:layout_marginRight="8dp" android:layout_toRightOf="@id/item_timeline_time"> <com.timelinedemo.CircleImageView android:id="@+id/item_timeline_icon_bg" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@android:color/transparent" app:civ_border_width="4dp" /> <ImageView android:id="@+id/item_timeline_icon" android:layout_width="24dp" android:layout_height="24dp" android:layout_centerInParent="true" android:scaleType="fitCenter" /> </RelativeLayout> <TextView android:id="@+id/item_timeline_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="18dp" android:layout_toRightOf="@id/item_timeline_icon_layout" android:text="今日收入" android:textColor="@color/colorPrimary" android:textSize="15sp" /> <TextView android:id="@+id/item_timeline_money" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/item_timeline_content" android:layout_marginTop="8dp" android:layout_toRightOf="@id/item_timeline_icon_layout" android:text="$ 100" android:textColor="@color/colorPrimary" android:textSize="22sp" /> <View android:id="@+id/item_timeline_view" android:layout_width="2dp" android:layout_height="60dp" android:layout_alignLeft="@id/item_timeline_icon_layout" android:layout_below="@id/item_timeline_icon_layout" android:layout_marginLeft="23dp" android:background="@color/colorAccent" /> </RelativeLayout>
Activity.Java
public class MainActivity extends AppCompatActivity { private RecyclerView recyclerView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initLayout(); } private void initLayout(){ recyclerView= (RecyclerView) findViewById(R.id.recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setHasFixedSize(true); recyclerView.setItemAnimator(new DefaultItemAnimator()); initData(); } private void initData(){ List<TimeInfo > list=new ArrayList<>(); for(int i=0;i<15;i++){ list.add(new TimeInfo()); } TimelineAdapter mAdapter = new TimelineAdapter(this, list); recyclerView.setAdapter(mAdapter); } }
添加依賴庫:
compile 'com.android.support:recyclerview-v7:23.0.0'
看完上述內(nèi)容,你們掌握Android開發(fā)中使用RecyclerView怎么實現(xiàn)一個時光軸效果的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
網(wǎng)頁標(biāo)題:Android開發(fā)中使用RecyclerView怎么實現(xiàn)一個時光軸效果
URL分享:http://aaarwkj.com/article22/ggphcc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、動態(tài)網(wǎng)站、網(wǎng)站維護(hù)、企業(yè)網(wǎng)站制作、、小程序開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)