Android实现课程表界面布局示例

发布时间:2020-10-29 15:05:30

来源:亿速云

阅读:113

作者:Leah

这篇文章运用简单易懂的例子给大家介绍Android实现课程表界面布局示例,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

实现步骤

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"/>

关于Android实现课程表界面布局示例就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐