android 开发笔记 时间轴开发

先上效果图

这里写图片描述

图片有点大我就不管了 。。。

时间轴我也是第一次写,其实就是一个ListView ,在item布局中做文章,竖的时间轴用点9图片或者用View 写个占全部高度的颜色线 ,下面献上我的布局代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="03/07"
        android:textStyle="bold"
        android:textSize="18dp"
        android:layout_marginTop="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="20dp"/>

    <TextView
        android:id="@+id/time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@id/date"
        android:layout_below="@id/date"
    android:text="17:23:12"/>
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_toRightOf="@id/date"
        android:src="@drawable/time_2"
        android:id="@+id/time2"
        android:background="#60a4ea"
        android:scaleType="fitXY"
        android:layout_marginLeft="4.5dp"/>
    <ImageView
        android:id="@+id/time3"
        android:layout_width="11dp"
        android:layout_height="11dp"
        android:src="@mipmap/time_3"
        android:layout_alignBottom="@+id/date"
        android:layout_toRightOf="@id/date"/>

    <LinearLayout
        android:layout_width="260dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_toRightOf="@id/time3"
        android:layout_alignTop="@id/date"
        android:background="@mipmap/time_4">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:paddingLeft="10dp"
                android:text="文书登记"/>

            <TextView
                android:id="@+id/tijao"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@mipmap/time_5"
                android:layout_alignParentRight="true"
                android:textColor="@color/whilte"
                android:layout_centerVertical="true"
                android:text="提交"
                android:textSize="10sp"
                android:gravity="center"
                android:layout_margin="10dp"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@mipmap/time_6"
                android:textColor="@color/whilte"
                android:layout_toLeftOf="@id/tijao"
                android:layout_centerVertical="true"
                android:textSize="10sp"
                android:gravity="center"
                android:text="完成"/>
        </RelativeLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginLeft="6dp"
            android:background="@color/gray"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="李东(LIDONG)"
            android:layout_margin="10dp"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="李东(LIDONG)"
            android:layout_margin="10dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="李东(LIDONG)"
            android:layout_margin="10dp"/>

    </LinearLayout>



</RelativeLayout>

下面是ListView 代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/lc_listview"
        android:divider="#00000000"
        android:dividerHeight="0dip"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </ListView>

</LinearLayout>

让后就是渲染数据java代码(我并没有渲染数据,都是写死的)

   //初始化视图
    private void initView() {
        mView = View.inflate(context, R.layout.dblcxq_view,null);
        listView = (ListView) mView.findViewById(R.id.lc_listview);
        initData();
        listView.setAdapter(new LcxqAdapter(datas,context));
        //这里调用了测量ListView 高度的方法
        ListViewUtils.setListViewHeightBasedOnChildren(listView);
    }

    //初始化数据源
    private void initData() {
        datas = new ArrayList();
        datas.add(1);
        datas.add(1);
        datas.add(1);
        datas.add(1);
        datas.add(1);
    }

适配器代码:


public class LcxqAdapter extends BaseViewAdapter{

    public LcxqAdapter(List list, Context context) {
        super(list, context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return View.inflate(context, R.layout.dblcxq_view_item, null);
    }
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值