android 课表布局,Android开发高仿课程表的布局实例详解

编程入门 行业动态 更新时间:2024-10-16 20:32:40

android 课表<a href=https://www.elefans.com/category/jswz/34/1770549.html style=布局,Android开发高仿课程表的布局实例详解"/>

android 课表布局,Android开发高仿课程表的布局实例详解

先说下这个demo,这是一个模仿课程表的布局文件,虽然我是个菜鸟,但我还是想留给学习的人一些例子,先看下效果

然后再来看一下我们学校的app

布局分析

先上一张划分好了的布局图

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

1:这个没什么好讲的,就是直接一个LinearLayout布局,然后将控件一个TextView用来显示年份,一个View用来当作竖线,一个Spinner用来显示选择周数

2:这个是显示星期几的部件,是我自定义的View,自己重写onDraw方法,然后画出七个字,代码如下:

public void onDraw(Canvas canvas)

{

//获得当前View的宽度

int width = getWidth();

int offset = width / 8;

int currentPosition = offset;

//设置要绘制的字体

mPaint.setTypeface(Typeface.create(Typeface.DEFAULT_BOLD, Typeface.BOLD));

mPaint.setTextSize(30);

mPaint.setColor(Color.rgb(0, 134, 139));

for(int i = 0; i < 7 ; i++)

{

//圈出当前的日期

if( day == i)

{

System.out.println("画出当前的日期!");

}

canvas.drawText(days[i], currentPosition, 30, mPaint);

currentPosition += offset;

}

//调用父类的绘图方法

super.onDraw(canvas);

}

3:这个也是一个LinearLayout,直接手写布局,将写出来的,将LinearLayout的orientation 属性设置为vertical 。

4:这是一个GridView ,然后自己继承BaseAdapter 填充内容,下面放上布局的xml文件

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

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 课表布局,Android开发高仿课程表的布局实例详解

本文发布于:2024-02-25 19:41:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1700089.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布局   课程表   课表   详解   实例

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!