Android学习之路(2)--奖牌列表(布局嵌套)--2017_01_10
来源:互联网 发布:linux查看被占用的内存 编辑:程序博客网 时间:2024/04/28 10:00
昨天发表了一篇简单的计算器实例的博客,计算器是在一个LinearLayout中完成的各项功能,今天这篇博客的内容是使用布局嵌套,本实例主要是将线性布局与表格布局混合起来显示,即总的布局为垂直方向向上的布局,上面那个布局内部又是垂直方向的布局,下面那个布局也是线性布局,不过里面有一个表格,总共四个布局。
mian.xml的布局图片就不发了,大家直接看xml代码
main.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#aabbcc" android:orientation="vertical" tools:context="com.example.tigermini.themedallist.MainActivity"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1"> <TextView android:id="@+id/London" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="伦敦奥运" android:textSize="5pt" android:background="#00ff00" android:layout_gravity="center_horizontal" android:padding="10pt" android:layout_weight="1"/> <TextView android:id="@+id/China" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="中国加油" android:textSize="8pt" android:background="#ff00ff" android:layout_weight="3"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="3"> <TableLayout android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="0,1,2,3"> <TableRow> <TextView android:text="国家" android:background="#848484" android:padding="2dp"/> <TextView android:text="金牌" android:background="#ff0000" android:padding="2dp"/> <TextView android:text="银牌" android:background="#0000ff" android:padding="2dp"/> <TextView android:text="铜牌" android:background="#00ff00" android:padding="2dp"/> </TableRow> <TableRow> <TextView android:text="中国" android:background="#848484" android:padding="2dp"/> <TextView android:text="*" android:background="#ff0000" android:padding="2dp"/> <TextView android:text="**" android:background="#0000ff" android:padding="2dp"/> <TextView android:text="***" android:background="#00ff00" android:padding="2dp"/> </TableRow> <TableRow> <TextView android:text="美国" android:background="#848484" android:padding="2dp"/> <TextView android:text="*" android:background="#ff0000" android:padding="2dp"/> <TextView android:text="**" android:background="#0000ff" android:padding="2dp"/> <TextView android:text="***" android:background="#00ff00" android:padding="2dp"/> </TableRow> </TableLayout> </LinearLayout></LinearLayout>
下面是MainActivity.java的代码,没有一点改动,所有内容都在main.xml布局里面。
MainActivity.javapackage com.example.tigermini.themedallist;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); }}
附上CSDN源代码的网址
http://download.csdn.net/detail/wjy1025104554/9733491
0 0
- Android学习之路(2)--奖牌列表(布局嵌套)--2017_01_10
- android布局学习--嵌套布局
- Linux学习-2016_01_10
- Android布局之联系人列表
- Android学习笔记之布局(2)
- Android开发之嵌套布局的使用
- Android之Fragment的嵌套布局
- HTML5学习之五嵌套列表、自定义列表
- python之列表推导式及嵌套列表解析学习
- 第17章、布局Layouts之嵌套布局(从零开始学Android)
- Android学习之路2 Activity 之布局
- Android 常用布局 -- Android 学习之路
- 学习android之布局
- Android学习之布局
- android中的布局--嵌套布局
- android中的布局--嵌套布局
- Android碎片知识总结之布局、列表
- Android 动态生成布局 (多层嵌套)
- RabbitMQ分布式集群架构
- Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSLocalizedDescription=unsuppor
- SecureCRT 双击或选中文字,自动换行的解决办法
- selenium基于python的环境配置
- Android之IntentService的使用
- Android学习之路(2)--奖牌列表(布局嵌套)--2017_01_10
- Android用户界面设计
- 虚机打不开报failed to lock the file错误原因及解决方案
- MyBatis基本配置和简单的增删改查
- python遍历文件夹
- CSS样式截取字符串
- Android 系列 6.14通过旋转器类提供下拉选择器
- CodeForces-748B
- 在CentOS6上安装Apache Sorl 6.3.0