【UI】时间轴自定义竖直分割线
来源:互联网 发布:eclipse开发java项目 编辑:程序博客网 时间:2024/05/17 06:35
xml布局
<!--时间轴--> <FrameLayout android:id="@+id/fl_time_line" android:layout_width="wrap_content" android:layout_toRightOf="@id/tv_time_history_erp_detail" android:layout_marginLeft="8dp" android:layout_height="match_parent"> <ImageView android:id="@+id/line_normal_erp_detail" android:layout_width="wrap_content" android:layout_height="match_parent" android:scaleType="fitXY" android:layout_gravity="center_horizontal" android:background="@drawable/icon_time_line" /> <ImageView android:layout_gravity="center_horizontal" android:id="@+id/iv_point_history_erp_detail" android:layout_width="9dp" android:layout_height="9dp" android:background="@drawable/bg_circle_solid_grey_e0" /> </FrameLayout>
如此布局并不能解决竖直分割线的显示(效果如图)
布局文件不能保证竖直分割线的自适应显示,因此需要再代码文件里进行相应的处理
代码如下
ImageView timeLine= (ImageView) historyItemView.findViewById(R.id.line_normal_erp_detail);int height= LayoutUtils.getViewHeight(historyItemView);FrameLayout.LayoutParams params=new FrameLayout.LayoutParams(1, height);timeLine.setLayoutParams(params);
效果如图,竖直线没有居中。
再添加params.gravity= Gravity.CENTER_HORIZONTAL;
完整代码如下:
ImageView timeLine= (ImageView) historyItemView.findViewById(R.id.line_normal_erp_detail);int height= LayoutUtils.getViewHeight(historyItemView);FrameLayout.LayoutParams params=new FrameLayout.LayoutParams(1, height);params.gravity= Gravity.CENTER_HORIZONTAL;//居中设置timeLine.setLayoutParams(params);
完善后的效果如图
0 0
- 【UI】时间轴自定义竖直分割线
- 时间分割线
- ListView自定义分割线
- TableViewCell自定义分割线
- TableViewCell自定义分割线
- UITableViewCell自定义分割线
- UITableViewCell自定义分割线
- 自定义cell分割线
- TableViewCell自定义分割线
- tableView 自定义分割线
- 自定义的分割线
- 自定义tableview分割线
- UITableView 自定义分割线
- UITabViewCell自定义分割线
- RecyclerView自定义分割线
- RecyclerView自定义分割线
- 自定义ExpandableListView分割线
- RecyclerView自定义分割线
- Centos7 yum安装 Docker
- 操作系统实验——信号量
- iOS设计模式-策略模式
- hive中regexp_extract的用法总结
- 通过淘宝司法拍卖购买房子,需要注意些什么?
- 【UI】时间轴自定义竖直分割线
- 数据结构与算法分析笔记与总结(java实现)--字符串4:表示数值的字符串
- Java Cache系列之Guava Cache
- Spark 转换
- Java short数组与byte数组互转
- Activity的生命周期大全
- 使用Google Guava来编写优雅的代码一Guava简介
- C++生成任意字符串
- 第二章 变量和基本类型——2.3 变量