iis服务器助手广告广告
返回顶部
首页 > 资讯 > 精选 >Android中怎么实现一个简易时间轴
  • 351
分享到

Android中怎么实现一个简易时间轴

android 2023-05-30 23:05:45 351人浏览 八月长安
摘要

这期内容当中小编将会给大家带来有关Android中怎么实现一个简易时间轴,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。新建一个自定义控件:public class WorkExcVie

这期内容当中小编将会给大家带来有关Android中怎么实现一个简易时间轴,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

新建一个自定义控件:

public class WorkExcView extends LinearLayout {private TextView dataLeft;private TextView dataRight;private TextView company;private TextView job;private TextView jobAsses;private TextView xiTong;private TextView ziTian;private LinearLayout jobContentContainer;private TextView jobContent;private LinearLayout commentContainer;private LinearLayout nianContentContainer;private TextView nianContent;private LinearLayout base;private LinearLayout yueXinGContainer;private TextView yueContent;private LinearLayout nianXingContainer;private TextView yueMoreContent;private TextView nianMoreContent;private String company_id;public WorkExcView(Context context) {  this(context,null);}public WorkExcView(Context context, AttributeSet attrs) {  super(context, attrs);  init();}private void init() {  View inflate = View.inflate(getContext(), R.layout.activity_four_workexcview, this);  dataLeft = (TextView) inflate.findViewById(R.id.workexcview_data_left);  dataRight= (TextView) inflate.findViewById(R.id.workexcview_data_right);  company = (TextView) inflate.findViewById(R.id.workexcview_company);  job = (TextView) inflate.findViewById(R.id.workexcview_job);  jobAsses = (TextView) inflate.findViewById(R.id.workexcview__job_asses);  xiTong = (TextView) inflate.findViewById(R.id.workexcview_xitong);  ziTian = (TextView) inflate.findViewById(R.id.workexcview_zitian);  jobContent = (TextView) inflate.findViewById(R.id.workexcview_jobcontent);  nianContent = (TextView) inflate.findViewById(R.id.workexcview_niancontent);  jobContentContainer = (LinearLayout)inflate.findViewById(R.id.workexcview_jobcontent_container);  commentContainer = (LinearLayout)inflate.findViewById(R.id.workexcview__comment_container);  nianContentContainer= (LinearLayout)inflate.findViewById(R.id.workexcview__niancontent_container);  base = (LinearLayout)inflate.findViewById(R.id.workexcview__base);  yueXingContainer = (LinearLayout)inflate.findViewById(R.id.workexcview_yuexing_container);  yueContent = (TextView)inflate.findViewById(R.id.workexcview_yuecontent);  nianXingContainer = (LinearLayout)inflate.findViewById(R.id.workexcview_nianxing_container);  yueMoreContent = (TextView)inflate.findViewById(R.id.workexcview_yuecontentmore);  nianMoreContent = (TextView)inflate.findViewById(R.id.workexcview_niancontentmore);}public void initData(final FourBean.JobsBean jobsBean) {   //赋值代码}

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"android:id="@+id/workexcview__base"android:paddingLeft="8dp"><RelativeLayout  android:layout_width="match_parent"  android:layout_height="wrap_content">  <ImageView    android:id="@+id/workexcview_landian"    android:layout_width="15dp"    android:layout_height="15dp"    android:layout_centerVertical="true"    android:src="@mipmap/landian" />  <TextView    android:id="@+id/workexcview_data_left"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_centerVertical="true"    android:layout_marginLeft="3Dp"    android:layout_toRightOf="@+id/workexcview_landian"    android:text="2016.03"    android:textColor="@color/text"    android:textSize="15sp" />  <TextView    android:id="@+id/workexcview__data_zhong"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_toRightOf="@id/workexcview_data_left"    android:text=" —— "    android:textColor="@color/text" />  <TextView    android:id="@+id/workexcview_data_right"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_centerVertical="true"    android:layout_toRightOf="@+id/workexcview__data_zhong"    android:text="2016.03"    android:textColor="@color/text"    android:textSize="15sp" />  <TextView    android:id="@+id/workexcview_zitian"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_alignParentRight="true"    android:background="@drawable/four_select"    android:padding="4dp"    android:paddingRight="6dp"    android:text="自填"    android:textColor="@color/red"    android:textSize="12sp"    android:visibility="Gone" />  <!--    <ImageView        android:id="@+id/workexcview_xitong"        android:layout_width="40dp"        android:layout_height="20dp"        android:layout_alignParentRight="true"        android:layout_centerVertical="true"        android:paddingRight="10dp"        android:src="@mipmap/xitong"        android:visibility="gone" />-->  <TextView    android:id="@+id/workexcview_xitong"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_alignParentRight="true"    android:background="@drawable/textview_shape"    android:padding="4dp"    android:paddingRight="6dp"    android:text="系统"    android:textColor="@color/holo_blue_light"    android:textSize="12sp"    android:visibility="gone" />  <RelativeLayout    android:id="@+id/four_setting_workexc_container"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_alignParentRight="true"    android:visibility="gone">    <TextView      android:id="@+id/four_setting_workexc_logo"      android:layout_width="wrap_content"      android:layout_height="wrap_content"      android:layout_alignParentRight="true"      android:layout_centerVertical="true"      android:text="编辑"      android:textColor="@android:color/holo_blue_light"      android:textSize="16sp" />    <ImageView      android:layout_width="20dp"      android:layout_height="20dp"      android:layout_centerVertical="true"      android:layout_toLeftOf="@+id/four_setting_workexc_logo"      android:src="@drawable/xierijidianji3x" />  </RelativeLayout></RelativeLayout><LinearLayout  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:orientation="horizontal">  <RelativeLayout    android:layout_width="wrap_content"    android:layout_height="match_parent">    <TextView      android:layout_width="1dp"      android:layout_height="match_parent"      android:layout_marginLeft="7dp"      android:background="@color/black" />  </RelativeLayout>  <LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:orientation="vertical">    <RelativeLayout      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:padding="8dp">      <TextView        android:id="@+id/workexcview_company"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_centerVertical="true"        android:text="某某公司"        android:textColor="@color/text"        android:textSize="14sp" />      <TextView        android:id="@+id/workexcview_company_zhong"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_centerVertical="true"        android:layout_toRightOf="@id/workexcview_company"        android:text=" / "        android:textColor="@color/text"        android:textSize="14sp" />      <TextView        android:id="@+id/workexcview_job"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_centerVertical="true"        android:layout_toRightOf="@id/workexcview_company_zhong"        android:text="WEB前段工程师"        android:textColor="@color/text"        android:textSize="14sp" />    </RelativeLayout>    <LinearLayout      android:id="@+id/workexcview_jobcontent_container"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:layout_marginLeft="5dp"      android:orientation="vertical"      android:padding="8dp">      <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="工作描述:"        android:textColor="@color/text" />      <TextView        android:id="@+id/workexcview_jobcontent"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="3dp"        android:text="巴拉巴拉" />    </LinearLayout>    <LinearLayout      android:id="@+id/workexcview__yuecontent_container"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:layout_marginLeft="5dp"      android:orientation="vertical"      android:padding="8dp"      android:visibility="visible">      <RelativeLayout        android:layout_width="match_parent"        android:layout_height="wrap_content">        <TextView          android:id="@+id/workexcview_yuecontent_logo"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_centerVertical="true"          android:text="最新月评价:"          android:textColor="@color/text" />        <LinearLayout          android:layout_centerVertical="true"          android:id="@+id/workexcview_yuexing_container"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:orientation="horizontal"          android:layout_toRightOf="@+id/workexcview_yuecontent_logo"          >        </LinearLayout>        <TextView          android:layout_alignParentRight="true"          android:id="@+id/workexcview_yuecontentmore"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_marginTop="3dp"          android:gravity="center"          android:padding="2dp"          android:layout_centerVertical="true"          android:background="@drawable/textview_shape"          android:text="更多"          android:textColor="@color/blue_title" />      </RelativeLayout>      <TextView        android:id="@+id/workexcview_yuecontent"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="3dp"        android:text="无"        android:textColor="@color/gray" />    </LinearLayout>    <LinearLayout      android:id="@+id/workexcview__niancontent_container"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:layout_marginLeft="5dp"      android:orientation="vertical"      android:padding="8dp"      android:visibility="visible">      <RelativeLayout        android:layout_width="match_parent"        android:layout_height="wrap_content">        <TextView          android:id="@+id/workexcview_niancontent_logo"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_centerVertical="true"          android:text="最新年评价:"          android:textColor="@color/text" />        <LinearLayout          android:layout_centerVertical="true"          android:id="@+id/workexcview_nianxing_container"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:orientation="horizontal"          android:layout_toRightOf="@id/workexcview_niancontent_logo"          >        </LinearLayout>        <TextView          android:id="@+id/workexcview_niancontentmore"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_marginTop="3dp"          android:padding="2dp"          android:layout_centerVertical="true"          android:background="@drawable/textview_shape"          android:text="更多"          android:layout_alignParentRight="true"          android:textColor="@color/blue_title" />      </RelativeLayout>      <TextView        android:id="@+id/workexcview_niancontent"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="3dp"        android:text="无"        android:textColor="@color/gray" />    </LinearLayout>    <LinearLayout      android:id="@+id/workexcview__comment_container"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:layout_margin="5dp"      android:orientation="vertical"      android:padding="8dp"      android:visibility="visible">      <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="离职评价:"        android:textColor="@color/text" />      <TextView        android:id="@+id/workexcview__job_asses"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="3dp"        android:text=""        android:textColor="@color/gray" />    </LinearLayout>  </LinearLayout> </LinearLayout></LinearLayout>

使用方式:其实很简单,直接for循环new出来赋值就行啦,因为本身就是一个自定义控件~

  fourWorkexcContainer.removeAllViews();  for (int i = 0; i < jobs.size(); i++) {    FourBean.JobsBean jobsBean = jobs.get(i);    WorkExcView workExcView = new WorkExcView(getContext());    workExcView.initData(jobsBean);    fourWorkexcContainer.addView(workExcView);  }

上述就是小编为大家分享的Android中怎么实现一个简易时间轴了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注编程网精选频道。

--结束END--

本文标题: Android中怎么实现一个简易时间轴

本文链接: https://www.lsjlt.com/news/221913.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Android中怎么实现一个简易时间轴
    这期内容当中小编将会给大家带来有关Android中怎么实现一个简易时间轴,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。新建一个自定义控件:public class WorkExcVie...
    99+
    2023-05-30
    android
  • android自定义控件是怎么实现简易时间轴
    这篇文章主要为大家分析了android自定义控件是怎么实现简易时间轴的相关知识点,内容详细易懂,操作细节合理,具有一定参考价值。如果感兴趣的话,不妨跟着跟随小编一起来看看,下面跟着小编一起深入学习“android自定义控件是怎么实现简易时间...
    99+
    2023-06-28
  • android自定义控件实现简易时间轴(1)
    本文实例为大家分享了android自定义控件实现简易时间轴的具体代码,供大家参考,具体内容如下 之前项目需要写一个消费记录,类似于时间轴似的控件,自身在自定义控件这里不咋地(&hel...
    99+
    2024-04-02
  • android自定义控件实现简易时间轴(2)
    这篇做了一个简单的时间轴控件。右侧的数据就是一个简单的字符串。问题还是有的,当右侧的文字长度不一样的时候就会有问题了。现在可以修改一下适配右侧的文字。 效果如下: 代码: priv...
    99+
    2024-04-02
  • android自定义控件如何实现简易时间轴
    这篇“android自定义控件如何实现简易时间轴”除了程序员外大部分人都不太理解,今天小编为了让大家更加理解“android自定义控件如何实现简易时间轴”,给大家总结了以下内容,具有一定借鉴价值,内容详细步骤清晰,细节处理妥当,希望大家通过...
    99+
    2023-06-28
  • 使用CSS3怎么实现一个时间轴效果
    这篇文章将为大家详细讲解有关使用CSS3怎么实现一个时间轴效果 ,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。什么是csscss是一种用来表现HTML或XML等文件样式的计算机语言,主要是用...
    99+
    2023-06-08
  • 如何在Android中利用View实现一个垂直时间轴布局
    这篇文章将为大家详细讲解有关如何在Android中利用View实现一个垂直时间轴布局,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。时间轴,顾名思义就是将发生的事件按照时间顺序罗列起来,给用户...
    99+
    2023-05-31
    android view roi
  • Android开发中使用RecyclerView怎么实现一个时光轴效果
    Android开发中使用RecyclerView怎么实现一个时光轴效果?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。如图:    &nb...
    99+
    2023-05-31
    android recyclerview recycle
  • CSS3中怎么实现时间轴动画
    这篇文章将为大家详细讲解有关CSS3中怎么实现时间轴动画,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。实现效果html<h3>CSS3 Timeline</h3><...
    99+
    2023-06-08
  • Android自定义控件实现时间轴
    本文实例为大家分享了Android自定义控件实现时间轴的具体代码,供大家参考,具体内容如下 由于项目中有需求,就简单的封装一个,先记录一下,有时间上传到github。 1、先增加自定...
    99+
    2024-04-02
  • php7怎么实现一个简易框架
    本篇内容主要讲解“php7怎么实现一个简易框架”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“php7怎么实现一个简易框架”吧!框架的核心链路是从开始的请求路由解析到控制器的分发,model的数据...
    99+
    2023-06-20
  • js怎么实现本地时间轴
    这篇文章主要介绍“js怎么实现本地时间轴”,在日常操作中,相信很多人在js怎么实现本地时间轴问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”js怎么实现本地时间轴”的疑惑有所帮助!接下来,请跟着小编一起来学习吧...
    99+
    2023-06-27
  • python实现一个简易hashmap
    ...
    99+
    2023-01-31
    简易 python hashmap
  • 手把手教你实现一个JavaScript时间轴组件
    目录这是开头开发时间准备工作中间的白色竖线时间刻度鼠标移动时显示所在时间拖动时间轴调整时间分辨率绘制时间段多个时间轴显示自定义元素总结这是开头 本文给大家带来一个时间轴的组件开发教程...
    99+
    2022-11-13
    JavaScript时间轴组件 JavaScript时间轴
  • Android开发中怎么自定义时间轴
    今天就跟大家聊聊有关Android开发中怎么自定义时间轴,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。具体内容如下 时间轴效果,实际上非常简单,就是listView中一个又一个的条目...
    99+
    2023-05-31
    android 时间轴 roi
  • vue怎么实现横向时间轴
    这篇文章给大家分享的是有关vue怎么实现横向时间轴的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。具体内容如下1、效果图2、代码实现 html<template>  <...
    99+
    2023-06-29
  • Vue怎么实现时间轴功能
    这篇文章主要介绍了Vue怎么实现时间轴功能的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Vue怎么实现时间轴功能文章都会有所收获,下面我们一起来看看吧。<template>  &...
    99+
    2023-06-29
  • Vue如何实现简单的时间轴与时间进度条
    目录前言1、封装时间尺度组件2、在vue页面使用时间尺度 3、组件init方法内 通过起止时间算出中间的所有时间尺度 总结前言 项目需要按天播放地图等值...
    99+
    2024-04-02
  • 如何实现一个简易promise
    这篇文章主要介绍如何实现一个简易promise,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!step1 搭建框架 首先我们需要在这里放置一个promise函数本体 后面要在里面添加resolve、reject的执行函...
    99+
    2023-06-25
  • Android TimeLine 时间节点轴的实现实例代码
    整理文档,搜刮出一个Android TimeLine 时间节点轴的实现实例代码,稍微整理精简一下做下分享。效果图具体实现 (RecyclerView)Adapterpackage com.haoren.timeline;import and...
    99+
    2023-05-31
    timeline android tim
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作