Android 时间轴的实现
来源:互联网 发布:c语言打印图形函数 编辑:程序博客网 时间:2024/05/16 07:30
直接上代码
xml布局:
<?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="wrap_content"> <View android:id="@+id/iew_1" android:layout_width="1dp" android:layout_height="0dp" android:layout_marginLeft="41dp" android:background="@color/light_gray" /> <RelativeLayout android:id="@+id/rl_title" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="20dp" android:layout_height="20dp" android:layout_centerVertical="true" android:layout_marginLeft="32dp" android:background="@mipmap/yuan" /> </RelativeLayout> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/iew_1" android:paddingBottom="20dp" android:layout_marginLeft="55dp" android:lineSpacingMultiplier="1.5" android:textColor="#A6A6A6" /> <View android:id="@+id/v_line" android:layout_width="1dp" android:layout_height="wrap_content" android:layout_below="@+id/rl_title" android:layout_marginLeft="41dp" android:background="@color/light_gray" /></RelativeLayout>
两个View实现的是与圆圈上下的两根竖线,ImageView实现就是圆圈
activity代码:
package app.view.home.insertclass;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.RelativeLayout;import android.widget.TextView;import org.xutils.view.annotation.ContentView;import org.xutils.view.annotation.ViewInject;import org.xutils.x;import app.R;/** * Created by sch on 2016/9/27. */@ContentView(R.layout.insert_class_catalog_group_content)public class ICCGroupContentAdapter extends BaseAdapter { Context context; private LayoutInflater inflater; @ViewInject(R.id.title) private TextView textView; @ViewInject(R.id.v_line) private View line; private View view; private String[] title = { "只手上飞机是克服了收款方sdfsafjaslfjlasdjlfjlsadjfladslfjldsajfldslfjldsfslafjlsjfpwelfmdslfjsflaslfjlasf式", "只手上飞机是克服了收款方sadfkasfnl式只", "回头啊,莫回头!曾经谁都曾回望自己的过去,但我从不曾想回头,是女孩也该向前进,找到更好的你自己,", " FB上面有一个视频,名字叫做Alwayslikeagirl。视频里采访了不同年龄段的人,有小男孩,也有女青年", "有一些姑娘,既能够画着淡妆,踩着小高跟,花枝招展,巧笑嫣然地出现在人前;也能够穿着旧T恤和短裤,连一口水都没时间喝却一句怨言都没有。" }; public ICCGroupContentAdapter(Context context) { this.context = context; } @Override public int getCount() { return title.length; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { inflater = LayoutInflater.from(parent.getContext()); View root = x.view().inject(this, inflater, parent); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) line.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.rl_title); params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.title); line.setLayoutParams(params); textView.setText(title[position]); return root; }}
代码解释:
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) line.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.rl_title); params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.title); line.setLayoutParams(params);这一部分代码是设置圆圈下面的竖线的高度,使其自适应高度
0 0
- Android 时间轴的实现
- Android时间轴的实现
- Android 时间轴的实现
- Android 时间轴的实现
- Android时间轴效果的实现
- Android自定义时间轴的实现
- Android自定义时间轴的实现
- Android时间轴效果的实现
- Android自定义简单时间轴的实现
- Android时间轴效果的实现
- Android时间轴(Timeline)效果的实现
- Android TimeLine 时间节点轴的实现
- Android实现时间轴
- android 时间轴实现
- Android实现时间轴
- android时间轴效果实现
- Android仿快递物流时间轴的代码实现
- Android时间轴(Timeline)效果的实现(使用RecyclerView)
- MFC多文档--在对话框中获取视图指针
- 2016年,作为前端我需要学习必备技能
- Delegate未设为nil导致的thread 1:exc_bad_access(code=EXC_I386_GPFLT)
- Uva 8道比较水的数论 (练练英语阅读理解)
- QuaZip的源码编译和生成DLL后的使用总结
- Android 时间轴的实现
- 服务器遭受攻击的解决办法
- Android事件的分发机制
- 递归函数
- android之switch控件的用法
- Haskell 5
- poj 2377
- javascript基础笔记(一)之js的简介
- Linux SVN 搭建(YUM)安装