安卓时间线布局及多样进度源码

showcase.png

Line Padding around marker

<com.github.vipulasri.timelineview.TimelineView
    android:id="@+id/timeline"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:markerSize="20dp"
    app:lineWidth="2dp"
    app:startLineColor="@color/colorPrimary"
    app:endLineColor="@color/colorPrimary"
    app:linePadding="5dp"/>
  • Configure using xml attributes or setters in code:

    Attribute NameDefault ValueDescription
    app:marker="@drawable/marker"Green Colored Oval Drawablesets marker drawable
    app:markerSize="25dp"25dpsets marker size
    app:markerInCenter="false"truesets the marker in center of line if `true`
    app:startLineColor="@color/primarColor"Dark Grey Linesets start line color
    app:endLineColor="@color/primarColor"Dark Grey Linesets end line color
    app:lineWidth="2dp"2dpsets line width
    app:lineOrientation="horizontal"verticalsets orientation of line ie `horizontal` or `vertical`
    app:linePadding="5dp"0dpsets line padding around marker
    app:lineStyle="dash"normalsets line style ie `normal` or `dashed`
    app:lineStyleDashGap="4dp"4dpsets line dash gap
    app:lineStyleDashLength="8dp"8dpsets line dash length
  • RecyclerView Holder : Your RecyclerViewHolder should have an extra parameter in constructor i.e viewType from onCreateViewHolder. You would also have to call the method initLine(viewType) in constructor definition.

    public class TimeLineViewHolder extends RecyclerView.ViewHolder {        public  TimelineView mTimelineView;        public TimeLineViewHolder(View itemView, int viewType) {            super(itemView);
            mTimelineView = (TimelineView) itemView.findViewById(R.id.timeline);
            mTimelineView.initLine(viewType);
        }
    }
  • RecyclerView Adapter : override getItemViewType method in Adapter

    @Override
    public int getItemViewType(int position) {        return TimelineView.getTimeLineViewType(position, getItemCount());
    }

And pass the viewType from onCreateViewHolder to its Holder.

    @Override
    public TimeLineViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {        View view = View.inflate(parent.getContext(), R.layout.item_timeline, null);        return new TimeLineViewHolder(view, viewType);
    }

源码下载

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值