02-03Android学习进度报告三
今天主要学习了线性布局和相对布局的概念和区别,以及线性布局和相对布局的优缺点。
经过搜素发现,我们屏幕适配的使用用的比较多的就是LinearLayout的权重属性weight,我
学习了一些 LinearLayout基础知识,包括一些基本的属性,Weight属性的使用。
例如实现权重1:1的界面划分,,只需要分别把两个LinearLayout的weight改成1和1就可以了,
即按比例划分水平方向:将涉及到的View的android:width属性设置为0dp,然后设置为
android weight属性设置比例即可;类推,竖直方向,只需设android:height为0dp,然后设weight属性即可
例如如下代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"> <LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:background="#ADFF2F"
android:layout_weight="1"/> <LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:background="#DA70D6"
android:layout_weight="2"/> </LinearLayout>
然后是相对布局,首先我了解了兄弟组件,兄弟组件就是处于同一层次容器的组件
例如经典的梅花布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" > <!-- 这个是在容器中央的 --> <ImageView
android:id="@+id/img1"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
android:src="@drawable/pic1"/> <!-- 在中间图片的左边 -->
<ImageView
android:id="@+id/img2"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_toLeftOf="@id/img1"
android:layout_centerVertical="true"
android:src="@drawable/pic2"/> <!-- 在中间图片的右边 -->
<ImageView
android:id="@+id/img3"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_toRightOf="@id/img1"
android:layout_centerVertical="true"
android:src="@drawable/pic3"/> <!-- 在中间图片的上面-->
<ImageView
android:id="@+id/img4"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_above="@id/img1"
android:layout_centerHorizontal="true"
android:src="@drawable/pic4"/> <!-- 在中间图片的下面 -->
<ImageView
android:id="@+id/img5"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_below="@id/img1"
android:layout_centerHorizontal="true"
android:src="@drawable/pic5"/> </RelativeLayout>
二者区别:
相对布局的主要思想是相对一个组件的位置确定另一个组件的位置
而线性布局主要是思想是按照水平方向和竖直方向按权重weight进行划分和布局
02-03Android学习进度报告三的更多相关文章
- 本周java 学习进度报告
本周java 学习进度报告 本周对我的感触很深,因为这是我初学java 语言的第一周,我认识到java 和c语言是有很多的不同之处和相同之处.我这几天几乎是在研究java 基础入门知识,而并没有太多的 ...
- 02-01 Android学习进度报告一
前两天,刚刚安装好有关Android开发有关的软件并配好了环境,有一些体会想要发表. 首先我了解到有一款专门用于Android开发的软件,叫做Android Studio ,是一个IDE集成软件 于是 ...
- 02-12Android学习进度报告十二
今天学习了ListView的焦点问题,基本了解了ListView的使用内容. 首先可以为抢占了控件的组件设置:android:focusable="false" 只需为抢占了Lis ...
- 02-07Android学习进度报告七
今天主要学习了关于Android开发的Date和Time组件部分内容. 首先看TextClock: 可以通过调用:TextClock提供的is24HourModeEnabled()方法来查看,系统是否 ...
- 02-06Android学习进度报告六
今天学习了关于Android开发中常用的两个知识,即对话框和悬浮框. 首先我学习了对话框的基本使用流程 Step 1:创建AlertDialog.Builder对象: Step 2:调用setIcon ...
- 02-05Android学习进度报告五
今天主要学习了关于Android 开发的关于进度条和拖动条的知识. 主要学习了一些关于进度条的基本属性: android:max:进度条的最大值 android:progress:进度条已完成进度值 ...
- 02-04Android学习进度报告四
今天主要学习Android界面的构建,包括Textview.EdixtText.Button等元素的应用. 关于Textview,主要是以下属性: id:为TextView设置一个组件id,根据id, ...
- 02-16Android学习进度报告十六
今天主要学习了GridView(网格视图)的基本使用和一些基本概念. 下面是GridView中的一些属性: android:columnWidth:设置列的宽度 android:gravity:组件对 ...
- 02-15Android学习进度报告十五
今天学习了关于ListView Item多布局的实现.感觉有点困难. 何为ListView Item多布局,打个比方,QQ这种聊天列表 代码示例如下: public class MutiLayoutA ...
随机推荐
- 入门chrome插件开发教程和经验总结,一篇就搞掂!
版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/weixin_44244857/articl ...
- innerAudiocontext的坑
链接:https://blog.csdn.net/sourcemyx/article/details/79424004 像wx.onNetworkStatusChange(function(){})回 ...
- java篇 之 抽象
Abstract(抽象): Public abstract void work(); <==> public void work(){ } 抽象方法,存在于抽象类中, 提供一个方 ...
- 疫情下的在线上课方案:QQ直播+蓝墨云班课
目录 疫情下的在线上课方案:QQ群视频(腾讯课堂)+蓝墨云班课 使用QQ进行直播 材料 QQ直播步骤 其他问题 使用蓝墨云班课加强学习效果 教材问题 我的直播-小学生硬笔书法基础 我的直播 - C程序 ...
- LVS、Tomcat、Nginx、PHP优化项
一.LVS 性能调优的方法最佳实践1.最小化安装编译系统内核2.优化持久服务超时时间: 1)显示超时时间 #ipvsadm -Ln --timeout #Timeout (tcp t ...
- Shiro入门学习之散列算法与凭证配置(六)
一.散列算法概述 散列算法一般用于生成数据的摘要信息,是一种不可逆的算法,一般适合存储密码之类的数据,常见的散列算法如MD5.SHA等,一般进行散列时最好提供一个salt(“盐”),什么意思?举个栗子 ...
- C语言:对传入sp的字符进行统计,三组两个相连字母“ea”"ou""iu"出现的次数,并将统计结果存入ct所指的数组中。-在数组中找出最小值,并与第一个元素交换位置。
//对传入sp的字符进行统计,三组两个相连字母“ea”"ou""iu"出现的次数,并将统计结果存入ct所指的数组中. #include <stdio.h& ...
- PHP的isset(),is_null,empty()你了解了没?
这几个变量判断函数在PHP开发中用的其实挺多的,而且粗看上去都差不多,但其实还是有不少的区别的,如果搞不清楚,也许就会遗留一些潜在的bug, 包括我自已也遇到过这样的坑,比如有一次我就遇到过用empt ...
- 【Go语言系列】第三方框架和库——GIN:GIN介绍
1.Gin 是什么? Gin 是一个用 Go (Golang) 编写的 HTTP web 框架. 它是一个类似于 martini 但拥有更好性能的 API 框架, 由于 httprouter,速度提高 ...
- Bugku-CTF社工篇之简单的社工尝试