时间:2021-05-20
前言
Android课程表布局实现
我是个菜鸟,文章供参考
示例
图1:
图2:
布局分析
该界面主要可分为三部分:
1.显示年份及周数部分
2.显示周一到周日
3.课程显示部分
实现步骤
1.首先整个页面放在一个LinearLayout布局下面,分为上面和下面两个部分,下面一个是显示课程表的详细信息
2.将控件一个TextView用来显示年份,一个View用来当作竖线,再用一个LinearLayout用来显示选择周数
3.使用ScrollView来显示课程表的详细信息
话不多说直接给代码!!!
代码如下:
显示课程表的详细信息代码如下(Fragment内的内容):
<?xml version="1.0" encoding="utf-8"?><!--模仿课程表的界面--><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/qq5"> <!--显示时间--> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white"> <TextView 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"/> <View android:layout_width="1dp" android:layout_height="match_parent" android:layout_marginLeft="20dp" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:background="#00FFFF" /> <TextView 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"/> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#00FF7F"/> <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:background="@android:color/white"> <TextView android:layout_width="25dp" android:layout_height="match_parent"/> <TextView android:layout_width="54dp" android:layout_height="match_parent" android:text="周一" android:textSize="20dp" android:textColor="@color/colorPrimaryDark" android:gravity="center"/> <TextView android:layout_width="54dp" android:layout_height="match_parent" android:text="周二" android:textSize="20dp" android:textColor="@color/colorPrimaryDark" android:gravity="center"/> <TextView android:layout_width="54dp" android:layout_height="match_parent" android:text="周三" android:textSize="20dp" android:textColor="@color/colorPrimaryDark" android:gravity="center"/> <TextView android:layout_width="54dp" android:layout_height="match_parent" android:text="周四" android:textSize="20dp" android:textColor="@color/colorPrimaryDark" android:gravity="center"/> <TextView android:layout_width="54dp" android:layout_height="match_parent" android:text="周五" android:textSize="20dp" android:textColor="@color/colorPrimaryDark" android:gravity="center"/> <TextView android:layout_width="54dp" android:layout_height="match_parent" android:text="周六" android:textSize="20dp" android:textColor="@color/colorPrimaryDark" android:gravity="center"/> <TextView android:layout_width="54dp" android:layout_height="match_parent" android:text="周日" android:textSize="20dp" android:textColor="@color/colorPrimaryDark" android:gravity="center"/> </LinearLayout> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="25dp" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center"> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:text="一" android:textSize="12dp" android:gravity="center"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorPrimaryDark"/> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:textSize="12dp" android:text="二" android:gravity="center"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorPrimaryDark"/> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:textSize="12dp" android:text="三" android:gravity="center"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorPrimaryDark"/> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:textSize="12dp" android:text="四" android:gravity="center"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorPrimaryDark"/> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:textSize="12dp" android:text="五" android:gravity="center"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorPrimaryDark"/> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:gravity="center" android:text="六" android:textSize="12dp" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorPrimaryDark"/> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:gravity="center" android:text="七" android:textSize="12dp" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorPrimaryDark"/> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:gravity="center" android:text="八" android:textSize="12dp" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorPrimaryDark"/> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:gravity="center" android:text="九" android:textSize="12dp" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorPrimaryDark"/> <TextView android:layout_width="wrap_content" android:layout_height="92dp" android:gravity="center" android:text="十" android:textSize="12dp" /> </LinearLayout> <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E5E5E5"/> <LinearLayout android:layout_width="54dp" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="185dp" android:id="@+id/o_text1" android:background="#00FFFF" android:text="乒乓球@地下室一层" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/o_tex2" android:layout_width="50dp" android:layout_height="185dp" android:background="#00FFFF" android:text="面向对象程序设计@4号楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/o_tex3" android:layout_width="50dp" android:layout_height="185dp" android:background="#00FFFF" android:text="大学体育@A区游泳馆" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/o_tex4" android:layout_width="50dp" android:layout_height="185dp" android:background="#00FFFF" android:text="面向对象程序设计@3号楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/o_tex5" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> </LinearLayout > <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E5E5E5"/> <LinearLayout android:layout_width="54dp" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="185dp" android:id="@+id/t_text1" android:text="高等数学@3号楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/t_tex2" android:layout_width="50dp" android:layout_height="185dp" android:text="大学英语@汇文楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/t_tex3" android:layout_width="50dp" android:layout_height="185dp" android:text="大学物理@3号楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/t_tex4" android:layout_width="50dp" android:layout_height="185dp" android:text="电路与电子技术@3号楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/t_tex5" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> </LinearLayout > <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E5E5E5"/> <LinearLayout android:layout_width="54dp" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="185dp" android:id="@+id/th_text1" android:text="电路与电子技术@4号楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/th_tex2" android:layout_width="50dp" android:layout_height="185dp" android:text="大学英语@3号楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/th_tex3" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/th_tex4" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/th_tex5" android:layout_width="50dp" android:layout_height="185dp" android:text="形式与政策@汇文楼" android:textSize="23dp"/> </LinearLayout > <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E5E5E5"/> <LinearLayout android:layout_width="54dp" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="185dp" android:id="@+id/f_text1" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/f_tex2" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/f_tex3" android:layout_width="50dp" android:layout_height="185dp" android:text="电路与电子技术@3号楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/f_tex4" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/f_tex5" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> </LinearLayout > <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E5E5E5"/> <LinearLayout android:layout_width="54dp" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="185dp" android:id="@+id/fi_text1" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/fi_tex2" android:layout_width="50dp" android:layout_height="185dp" android:text="高等数学@3号楼" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/fi_tex4" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/fi_tex5" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> </LinearLayout > <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E5E5E5"/> <LinearLayout android:layout_width="54dp" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="185dp" android:id="@+id/s_text1" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/s_tex2" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/s_tex3" android:layout_width="50dp" android:layout_height="185dp" android:text="大学生心理健康教育" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/s_tex4" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/s_tex5" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> </LinearLayout > <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E5E5E5"/> <LinearLayout android:layout_width="54dp" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="185dp" android:id="@+id/se_text1" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/se_tex2" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/se_tex3" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/se_tex4" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5E5"/> <TextView android:id="@+id/se_tex5" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp"/> <TextView android:id="@+id/fi_tex3" android:layout_width="50dp" android:layout_height="185dp" android:textSize="23dp" /> </LinearLayout > <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E5E5E5"/> </LinearLayout> </ScrollView></LinearLayout>总结
我上面使用了Fragment,在Fragment中写课程信息。是因为我要实现底部导航栏,如果是直接写一个界面,可把Fragment内的内容直接写在第一个LinearLayout中。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
很多学生都在使用超级课程表,能够把学校安排的课程导入超级课程表中,方便随时随地查看,那么超级课程表如何导入课表呢?下面小编就来教一下大家。软件名称:超级课程表课
使用超级课程表app的伙伴们,你们知道在其中如何查空教室吗?本期文章就分享了超级课程表app中查空教室的具体操作方法。 1、首先打开超级课程表app,点击左
各位使用超级课程表app的同学们知道在其中如何将课程山删掉吗?本期文章就为你们分享了超级课程表app中将课程删掉的具体操作方法。 1、首先打开超级课程表a
余佳文,热点人物。超级课程表呢?作为两个相互联系的词,为什么超级课程表的出现率比余佳文少那么多?难道超级课程表的就没有值得提的设计?撇开这个热门的霸道创业者,他
使用word软件来制作课程表,课程表的制作,我们一般使用word的表格来制作。最终的课程表如图:软件名称:Word2003绿色精简版(单独word15M)软件大