前言

Android课程表布局实现

我是个菜鸟,文章供参考

示例

图1:

图2:

布局分析

该界面主要可分为三部分:

1.显示年份及周数部分

2.显示周一到周日

3.课程显示部分

实现步骤

1.首先整个页面放在一个LinearLayout布局下面,分为上面和下面两个部分,下面一个是显示课程表的详细信息

2.将控件一个TextView用来显示年份,一个View用来当作竖线,再用一个LinearLayout用来显示选择周数

3.使用ScrollView来显示课程表的详细信息

话不多说直接给代码!!!

代码如下:

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

tools:context=".Main3Activity">

android:id="@+id/content"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

>

android:layout_width="match_parent"

android:layout_height="60dp"

android:background="#FFFFFF">

android:id="@+id/layout1"

android:layout_width="0dp"

android:layout_height="match_parent"

android:layout_weight="1">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_centerVertical="true"

android:orientation="vertical">

android:id="@+id/text1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:layout_marginTop="5dp"

android:text="周一"

android:textColor="#7597B3" />

android:id="@+id/layout2"

android:layout_width="0dp"

android:layout_height="match_parent"

android:layout_weight="1">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_centerVertical="true"

android:orientation="vertical">

android:id="@+id/text2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:layout_marginTop="5dp"

android:text="周二"

android:textColor="#7597B3" />

android:id="@+id/layout3"

android:layout_width="0dp"

android:layout_height="match_parent"

android:layout_weight="1">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_centerVertical="true"

android:orientation="vertical">

android:id="@+id/text3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:layout_marginTop="5dp"

android:text="周三"

android:textColor="#7597B3" />

android:id="@+id/layout4"

android:layout_width="0dp"

android:layout_height="match_parent"

android:layout_weight="1">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_centerVertical="true"

android:orientation="vertical">

android:id="@+id/text4"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:layout_marginTop="5dp"

android:text="周四"

android:textColor="#7597B3" />

android:id="@+id/layout5"

android:layout_width="0dp"

android:layout_height="match_parent"

android:layout_weight="1">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_centerVertical="true"

android:orientation="vertical">

android:id="@+id/text5"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:layout_marginTop="5dp"

android:text="周五"

android:textColor="#7597B3" />

android:id="@+id/layout6"

android:layout_width="0dp"

android:layout_height="match_parent"

android:layout_weight="1">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_centerVertical="true"

android:orientation="vertical">

android:id="@+id/text6"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:layout_marginTop="5dp"

android:text="周六"

android:textColor="#7597B3" />

android:id="@+id/layout7"

android:layout_width="0dp"

android:layout_height="match_parent"

android:layout_weight="1">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_centerVertical="true"

android:orientation="vertical">

android:id="@+id/text7"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal"

android:layout_marginTop="5dp"

android:text="周日"

android:textColor="#7597B3" />

显示课程表的详细信息代码如下(Fragment内的内容):

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:background="@drawable/qq5">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@android:color/white">

android:id="@+id/year"

android:layout_width="wrap_content"

android:layout_height="50dp"

android:layout_gravity="center"

android:gravity="center"

android:layout_marginLeft="20dp"

android:textSize="20dp"

android:text="2020-2021"/>

android:layout_width="1dp"

android:layout_height="match_parent"

android:layout_marginLeft="20dp"

android:layout_marginTop="10dp"

android:layout_marginBottom="10dp"

android:background="#00FFFF"

/>

android:id="@+id/te1"

android:text="第八周"

android:gravity="center"

android:textColor="@color/colorPrimary"

android:textSize="25dp"

android:layout_width="match_parent"

android:layout_height="match_parent"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#00FF7F"/>

android:layout_width="match_parent"

android:layout_height="40dp"

android:background="@android:color/white">

android:layout_width="25dp"

android:layout_height="match_parent"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:text="周一"

android:textSize="20dp"

android:textColor="@color/colorPrimaryDark"

android:gravity="center"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:text="周二"

android:textSize="20dp"

android:textColor="@color/colorPrimaryDark"

android:gravity="center"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:text="周三"

android:textSize="20dp"

android:textColor="@color/colorPrimaryDark"

android:gravity="center"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:text="周四"

android:textSize="20dp"

android:textColor="@color/colorPrimaryDark"

android:gravity="center"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:text="周五"

android:textSize="20dp"

android:textColor="@color/colorPrimaryDark"

android:gravity="center"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:text="周六"

android:textSize="20dp"

android:textColor="@color/colorPrimaryDark"

android:gravity="center"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:text="周日"

android:textSize="20dp"

android:textColor="@color/colorPrimaryDark"

android:gravity="center"/>

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_width="25dp"

android:layout_height="match_parent"

android:orientation="vertical"

android:gravity="center">

android:layout_width="wrap_content"

android:layout_height="92dp"

android:text="一"

android:textSize="12dp"

android:gravity="center"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/colorPrimaryDark"/>

android:layout_width="wrap_content"

android:layout_height="92dp"

android:textSize="12dp"

android:text="二"

android:gravity="center"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/colorPrimaryDark"/>

android:layout_width="wrap_content"

android:layout_height="92dp"

android:textSize="12dp"

android:text="三"

android:gravity="center"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/colorPrimaryDark"/>

android:layout_width="wrap_content"

android:layout_height="92dp"

android:textSize="12dp"

android:text="四"

android:gravity="center"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/colorPrimaryDark"/>

android:layout_width="wrap_content"

android:layout_height="92dp"

android:textSize="12dp"

android:text="五"

android:gravity="center"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/colorPrimaryDark"/>

android:layout_width="wrap_content"

android:layout_height="92dp"

android:gravity="center"

android:text="六"

android:textSize="12dp" />

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/colorPrimaryDark"/>

android:layout_width="wrap_content"

android:layout_height="92dp"

android:gravity="center"

android:text="七"

android:textSize="12dp" />

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/colorPrimaryDark"/>

android:layout_width="wrap_content"

android:layout_height="92dp"

android:gravity="center"

android:text="八"

android:textSize="12dp" />

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/colorPrimaryDark"/>

android:layout_width="wrap_content"

android:layout_height="92dp"

android:gravity="center"

android:text="九"

android:textSize="12dp" />

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/colorPrimaryDark"/>

android:layout_width="wrap_content"

android:layout_height="92dp"

android:gravity="center"

android:text="十"

android:textSize="12dp" />

android:layout_width="1dp"

android:layout_height="match_parent"

android:background="#E5E5E5"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="185dp"

android:id="@+id/o_text1"

android:background="#00FFFF"

android:text="乒乓球@地下室一层"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/o_tex2"

android:layout_width="50dp"

android:layout_height="185dp"

android:background="#00FFFF"

android:text="面向对象程序设计@4号楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/o_tex3"

android:layout_width="50dp"

android:layout_height="185dp"

android:background="#00FFFF"

android:text="大学体育@A区游泳馆"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/o_tex4"

android:layout_width="50dp"

android:layout_height="185dp"

android:background="#00FFFF"

android:text="面向对象程序设计@3号楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/o_tex5"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="1dp"

android:layout_height="match_parent"

android:background="#E5E5E5"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="185dp"

android:id="@+id/t_text1"

android:text="高等数学@3号楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/t_tex2"

android:layout_width="50dp"

android:layout_height="185dp"

android:text="大学英语@汇文楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/t_tex3"

android:layout_width="50dp"

android:layout_height="185dp"

android:text="大学物理@3号楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/t_tex4"

android:layout_width="50dp"

android:layout_height="185dp"

android:text="电路与电子技术@3号楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/t_tex5"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="1dp"

android:layout_height="match_parent"

android:background="#E5E5E5"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="185dp"

android:id="@+id/th_text1"

android:text="电路与电子技术@4号楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/th_tex2"

android:layout_width="50dp"

android:layout_height="185dp"

android:text="大学英语@3号楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/th_tex3"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/th_tex4"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/th_tex5"

android:layout_width="50dp"

android:layout_height="185dp"

android:text="形式与政策@汇文楼"

android:textSize="23dp"/>

android:layout_width="1dp"

android:layout_height="match_parent"

android:background="#E5E5E5"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="185dp"

android:id="@+id/f_text1"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/f_tex2"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/f_tex3"

android:layout_width="50dp"

android:layout_height="185dp"

android:text="电路与电子技术@3号楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/f_tex4"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/f_tex5"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="1dp"

android:layout_height="match_parent"

android:background="#E5E5E5"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="185dp"

android:id="@+id/fi_text1"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/fi_tex2"

android:layout_width="50dp"

android:layout_height="185dp"

android:text="高等数学@3号楼"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/fi_tex4"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/fi_tex5"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="1dp"

android:layout_height="match_parent"

android:background="#E5E5E5"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="185dp"

android:id="@+id/s_text1"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/s_tex2"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/s_tex3"

android:layout_width="50dp"

android:layout_height="185dp"

android:text="大学生心理健康教育"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/s_tex4"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/s_tex5"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="1dp"

android:layout_height="match_parent"

android:background="#E5E5E5"/>

android:layout_width="54dp"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="185dp"

android:id="@+id/se_text1"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/se_tex2"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/se_tex3"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/se_tex4"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="#E5E5E5"/>

android:id="@+id/se_tex5"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp"/>

android:id="@+id/fi_tex3"

android:layout_width="50dp"

android:layout_height="185dp"

android:textSize="23dp" />

android:layout_width="1dp"

android:layout_height="match_parent"

android:background="#E5E5E5"/>

总结

我上面使用了Fragment,在Fragment中写课程信息。是因为我要实现底部导航栏,如果是直接写一个界面,可把Fragment内的内容直接写在第一个LinearLayout中。

android 自定义课程表,Android课程表界面布局实现代码相关推荐

  1. android 海浪动画,android自定义波浪加载动画的实现代码

    本文实例为大家分享了android自定义波浪加载动画的具体代码,供大家参考,具体内容如下 效果图 1.自定义控件 WaveView package com.example.wh.myapplicati ...

  2. Android自定义Adapter的ListView的思路及代码

    Android自定义Adapter的ListView的思路及代码,需要的朋友可以参考一下 width="650" height="200" align=&quo ...

  3. android自定义抽奖,Android自定义view制作抽奖转盘

    本文实例为大家分享了Android自定义view制作抽奖转盘的具体代码,供大家参考,具体内容如下 效果图 TurntableActivity package com.bawei.myapplicati ...

  4. android 自定义view画表格,Android自定义View实现课程表表格

    自己闲下来时间写的一个课表控件,使用的自定义LinearLayout,里面View都是用代码实现的,最终效果如下图,写的可能有问题希望多多指点 创建一个自定义LinearLayout 控件用来装载课程 ...

  5. android 自定义event,Android运用onTouchEvent自定义滑动布局

    写在自定义之前 我们也许会遇到,自定义控件的触屏事件处理,先来了解一下View类中的,onTouch事件和onTouchEvent事件. 1.boolean onTouch(View v, Motio ...

  6. Android自定义壁纸预览界面,Android仿主流壁纸App设置界面

    摘要:项目中做到在线壁纸应用,在壁纸设置界面也是参考了主流壁纸应用的做法,例如小米,vivo,搜狗等都是采用了类似下图的界面布局.这里将介绍如何做出类似布局和功能. 在图中,当手指滑动滑块的时候,背景 ...

  7. android 自定义relativelayout,Android布局(RelativeLayout、TableLayout等)使用方法

    本文介绍 Android 界面开发中最基本的四种布局LinearLayout.RelativeLayout.FrameLayout.TableLayout 的使用方法及这四种布局中常用的属性. Lin ...

  8. Android和iPhone应用程序界面布局示例

    下图是根据Android和iPhone这两个平台的"生产内容型的应用程序"整理出来的界面布局示例.所对比的4个点,均是两大平台的应用程序常规界面元素.   状态栏: Android ...

  9. Android自定义壁纸预览界面,Android自定义动态壁纸开发(时钟)

    看到有些手机酷炫的动态壁纸,有没有好奇过他们是如何实现的,其实我们自己也可以实现. 先看效果 上图是动态壁纸钟的一个时钟. 我们先来看看 Livewallpaper(即动态墙纸)的实现,Android ...

最新文章

  1. 匿名发差评被判赔3272元,北京研究生遭遇冲上热搜,涉事机构回应:暂不澄清...
  2. linux如何连接移动硬盘
  3. 版本控制 Git RPM打包
  4. Uipath 学习栏目基础教学:5Uipath流程控制语句-整合
  5. curl记录solr删除indexing
  6. 介绍了如何取成员函数的地址以及调用该地址
  7. jdk,jre,jvm的区别以及联系
  8. java 自动补齐数值至指定位数
  9. 移动端动画使用transform提升性能
  10. Java LP1_Java Performance 总结(1. Class Loader)
  11. 在VSCode中使用CUDA
  12. pycharm专业版使用
  13. 全球与中国高密度聚乙烯塑料桶市场深度研究分析报告
  14. auto semicolon insertion 自动分号补齐的坑
  15. USB PD快充协议详解(待续)
  16. 2016百度笔试题交流
  17. Unity5权威讲解 笔记
  18. 《REWORK》读记
  19. 【Hive】如何在 Hive 中创建外部表映射 Hbase 中已存在的表
  20. 走进VOT--《High Performance Visual Tracking with Siamese Region Proposal Network》阅读翻译

热门文章

  1. 设置远程桌面(一)修改Win7远程桌面端口
  2. gdiplustypes min max找不到标识符_当年月销过万的比亚迪宋MAX,为何突然不香了?...
  3. ios 数字键盘左下角添加按钮_IOS数字键盘左下角添加完成按钮的实现方法
  4. 抖音用计算机弹曲子,抖音计算机乐谱有哪些?抖音计算机乐谱大全分享
  5. oss图片尺寸调用方式_CDN百科11 | 如何用CDN加速OSS源站资源
  6. aopaspect区别_spring 中的aop:advisor和aop:aspect有什么区别?
  7. 前端flv.js设置缓冲时间和大小_不可不知的 WEB 前端网站优化 —— 雅虎 34 条军规...
  8. 中国风古典传统中式花纹边框图案PSD素材
  9. 更具时尚感的服饰购物APP设计灵感!
  10. 农信社计算机知识,农信社备考:计算机基础知识(15)