国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android之RecyclerView實現時光軸效果示例

2019-10-23 19:47:12
字體:
來源:轉載
供稿:網友

做項目的過程中有個需求需要時光軸,于是網上找了部分資料 ,寫了個案例,現在分享給大家。

如圖:

 android時光軸效果,android時光軸      

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'

由于代碼太多,完整代碼未給出,源碼直接下載即可

源碼點擊下載:TimeLineDemo.rar

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 山阴县| 冀州市| 东阿县| 尉氏县| 绥德县| 绍兴县| 通州区| 新乡县| 吴忠市| 桓仁| 聂荣县| 盐山县| 临猗县| 涿鹿县| 德保县| 吉首市| 盘山县| 历史| 怀集县| 洞头县| 临猗县| 留坝县| 黄石市| 镇原县| 临泉县| 滁州市| 盐津县| 南丰县| 晋江市| 冷水江市| 宜兰县| 宿松县| 文成县| 任丘市| 九龙城区| 都匀市| 榆树市| 永新县| 绥宁县| 乌鲁木齐县| 宁化县|