跟UI搞了很久,用.9方式展示,还是做不成那个感觉,最后用Android的shape编写这个页面,没有自定义控件。

先来看看这个效果图

有折角的页面的代码  shape 文件命名为 :bgll.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:id="@+id/color_bg1" ><shape android:shape="rectangle" ><corners android:radius="5.5dp"/><solid android:color="#FD9193" /></shape></item><item ><shape  android:shape="rectangle" ><corners android:radius="5.5dp"/><solid android:color="#30000000" /></shape></item><item  android:bottom="2dp" ><shape android:shape="rectangle" ><corners android:radius="5.5dp"/><solid android:color="#bbffffff" /></shape></item><item android:id="@+id/color_bg2" android:bottom="2dp" android:right="5.5dp"><shape android:shape="rectangle"><corners android:radius="5.5dp"/><solid android:color="#FD9193" /></shape></item><item android:id="@+id/color_bg3" android:bottom="7dp" ><shape android:shape="rectangle"><cornersandroid:bottomLeftRadius="5.5dp"android:bottomRightRadius="3dp"android:topLeftRadius="5.5dp"android:topRightRadius="5.5dp" /><solid android:color="#FD9193" /></shape></item></layer-list>

这段代码的效果图:

为了动态改变背景,在需要改变颜色的item里加了id。

在代码里使用案例:

textView.setBackgroundResource(R.drawable.bgll);
setbg("#"+colors_back[subject.getColorRandom()],textView);
private void setbg(String color,TextView view){LayerDrawable layerDrawable = (LayerDrawable) view.getBackground();GradientDrawable bg1 = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.color_bg1);GradientDrawable bg2 = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.color_bg2);GradientDrawable bg3 = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.color_bg3);bg1.setColor(Color.parseColor(color));bg2.setColor(Color.parseColor(color));bg3.setColor(Color.parseColor(color));
}

这个折页控件底部还有一个阴影的控件,也是shape绘制:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:id="@+id/color_line"><shape android:shape="rectangle"><corners android:radius="7dp" /><gradientandroid:angle="-90"android:endColor="#20FD9193"android:startColor="#c1FD9193" /><!-- 90阴影冲上,-90,阴影冲下--></shape></item>
</layer-list>

最后组件起来使用:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/id_course_item_framelayout"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/id_course_item_count"android:layout_width="match_parent"android:layout_height="17dp"android:layout_gravity="bottom"android:background="@drawable/shape_line1"android:gravity="center"/><TextViewandroid:id="@+id/id_course_item_course"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginBottom="3.9dp"android:layout_marginHorizontal="0.2dp"android:background="@drawable/bgll"android:gravity="left"android:padding="2.5dp"android:textColor="@color/app_white"android:textSize="12sp" /></FrameLayout>

最后的代码:

TextView textView = (TextView) view.findViewById(R.id.id_course_item_course);
TextView countTextView = (TextView) view.findViewById(R.id.id_course_item_count);
textView.setBackgroundResource(R.drawable.bgll);
setbg(color,textView);
setbgm(colors,countTextView);
private void setbg(String color,TextView view){LayerDrawable layerDrawable = (LayerDrawable) view.getBackground();GradientDrawable bg1 = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.color_bg1);GradientDrawable bg2 = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.color_bg2);GradientDrawable bg3 = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.color_bg3);bg1.setColor(Color.parseColor(color));bg2.setColor(Color.parseColor(color));bg3.setColor(Color.parseColor(color));
}
private void setbgm( int[] colors,TextView view1){GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, colors);gradientDrawable.setCornerRadius(23);view1.setBackground(gradientDrawable);
}

注意一点函数 setbgm() 里的 GradientDrawable  务必要new,不然会复用性,出现统一的阴影。原本我是这么写的:

LayerDrawable layerDrawable1 = (LayerDrawable) view1.getBackground();GradientDrawable line= (GradientDrawable) layerDrawable1.findDrawableByLayerId(R.id.color_line);line.setColors(colors);

这段代码不行,出现控件复用性。按照我那样写不出现问题。

Android模仿超级课表,展示多门课程重叠,页面有折角背景相关推荐

  1. 模仿超级课程表——抓取学校课表数据

    本文参考自:打造超级课程表 一.显示课表页面的制作 ①.介绍 用过的超标的同学都知道,超标的课表页面是可以滑动的,并且背景为透明色,可以任意修改背景. 效果展示: ②.制作流程 那么如何制作出这样的表 ...

  2. Java爬取frame的课程表_超级课程表一键提取课程功能app及课表静态网页内容

    [实例简介] 内含app具体代码,可以编译,但是无法运行,因为具体的链接涉及到隐私问题,被我屏蔽,要想正常导入自己教务处的课表,请修改HttpUtil.java里对应的链接信息. 里面还含有三张课表的 ...

  3. 大疆Android SDK API知识点讲解及课程最终demo展示

    大疆Android SDK API知识点讲解及课程最终demo展示 大疆Android SDK课程--主要讲解Android开发环境的搭建.如何连接无人机.获取摄像头信息以及如何导入高德地图到APP当 ...

  4. Android仿超级课程表开源控件

    # TimetableView(v1.x) TimetableView已经升级到v2.0.2了,新增了很多实用的功能 本文中的功能介绍.控件用法均针对v1.x,它并不是最新的,你可以在 Change ...

  5. android studio上下滚动菜单,Android模仿美团顶部的滑动菜单实例代码

    前言 本文主要给大家介绍了关于Android模仿美团顶部滑动菜单的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧. 先来看下效果图: 实现方法 这是通过 ViewPager ...

  6. android让字体左右对齐,Android 模仿微信读书文字左右对齐效果

    原标题:Android 模仿微信读书文字左右对齐效果 本文作者 作者:Amter https://www.jianshu.com/p/020786e22a6f 左右对齐的文字效果,很常见,在大多数文章 ...

  7. android 仿微信录音,Android 模仿微信长按录音功能

    Android 模仿微信长按录音功能 布局就两个button这里不多介绍了. 下面是activity内的代码 package com.example.forevercloud.myapplicatio ...

  8. 安卓Android系统超级终端命令行大全

    Android系统超级终端命令集萃 free 1.作用 free命令用来显示内存的使用情况,使用权限是所有用户. 2.格式 free [-b|-k|-m] [-o] [-s delay] [-t] [ ...

  9. 超级简单的安卓课程设计——书籍信息查询

    超级简单的安卓课程设计--书籍信息查询 快到期末了,老师让我们做课设,然后我做了一个没啥技术含量的安卓课设(丢人~~),现在我把代码分享一下(觉得垃圾的请别喷我),有些代码是老师之前上课的时候讲的,我 ...

  10. Android模仿iOS iMessages10照片选择器的实现

    不知不觉已经接近半年多没有写过博客了,这段时间,也是我刚好毕业走出校园的时间,由于学习工作的原因,一直没有真正静下心来写下些什么东西.这个星期刚入了小米笔记本pro的坑,本着新电脑新生活的理念嘻嘻-- ...

最新文章

  1. 语义分割:基于openCV和深度学习(一)
  2. linux启动程序api编程,Linux编程中关于API函数与系统调用间关系
  3. java设计模式:Singleton模式
  4. 常见人工智能比赛平台总结
  5. 排序:插入排序与希尔排序
  6. 在matlab中求协方差,matlab里面的求协方差函数
  7. 微信小程序 Image 图片实现宽度100%,高度自适应
  8. 蓝桥杯 ALGO-101 算法训练 图形显示
  9. qt html 案例,QT代替WebView的方法及使用例子
  10. 电子计算机的核心部件是哪三个,电子计算机三大核心部件 是什么
  11. 【前端安全】web缓存投毒
  12. 搭建GTK+开发环境
  13. 如何清除远程桌面连接记录
  14. JavaScript设置显示video第一帧
  15. Puppeteer之Pyppeteer——浏览某短视频,获取点赞和评论,收藏,转发数(5)
  16. 大一学生作品《前端框架开发技术》 期末网页制作 HTML+CSS+JavaScript 个人主页网页设计实例
  17. Ceph知识树和技能树
  18. linux下防止rm-rf /处理,削减删除的影响力!
  19. Final IK⭐五、FinalIK做布娃娃动画的过程
  20. basroot.dll丢失的解决方法_basroot.dll文件丢失修复教程

热门文章

  1. java仿QQ2.0版(一直忘了更)
  2. wacom win10 未连接任何设备 驱动的问题 解决影拓3手绘板等老设备驱动无法在win10使用的问题
  3. Codeforces edu 88(A~E)
  4. 基于JS和Canvas的小球碰撞动画演示
  5. 【遥感数字图像处理】实验:遥感影像增强方法大全处理看过来(Erdas版)
  6. 手机怎么用外嵌字幕_iphone 12发布 ! “预购、定金、尾款、换手机”用英语怎么说?...
  7. KOOCAN的影视资讯——那些惊艳到你的女鬼
  8. uploadify java实例_java uploadify 例子
  9. boost升压电路原理
  10. MongoVUE破解方法记录