首页 技术 正文
技术 2022年11月14日
0 收藏 936 点赞 2,320 浏览 2440 个字

笔记链接http://www.cnblogs.com/igoslly/p/6794344.html

一、ViewGroup

1、ViewGroup的意义——整合Layout多个不同View,并对其进行位置排列

Android开发笔记(2)——ViewGroup

Android开发笔记(2)——ViewGroup

2、ViewGroup种类

Linear Layout  简单直接的布局格式,只允许水平放置 / 垂直放置

Relative Layout  复杂生动的布局格式,可根据父 / 子View相对位置来设置


二、Layout

  • Anroid URL标记

         xmlns:android=”http://schemas.android.com/apk/res/android”

  在XML文件根视图开合标记中添加XML命名空间,和“android:”表示属于android属性。

  • 布局参数

众多属性里,涉及background、text、textSize均由TextView风格化视图处理

涉及layout_width\layout_height\layout_above为布局参数,由ViewGroup统一管理。

  • Linear Layout

1)   只允许整个布局全水平 / 全垂直放置

  android: orientation= ”vertical”

       android: orientation= ”horziontal”

Android开发笔记(2)——ViewGroup

2)      如何在不同设备屏幕上实现视图等分?

     固定长宽×

    layout_weight设置每个View的长宽权重,等比例放置

规则:

1)      配置固定长宽、wrap_contentView

2)      配置layout_weight

android:layout_width=”0dp”

android:layout_weight=“1”

3)      计算剩余空间

4)      分配剩余空间(全部占满

a)      当有且仅有一个View设置权重,无论值大小,均占满

b)      当两个及以上View设置权重,按照设置数值,等比例分配空间

c)      特殊情况:等分——保证所有View权重值相等

5)      当weight=0 / 不设置(默认为0)时,View大小不改变


  • Relative Layout

1)    相对于Parent View

    整个视图贴合四条边,设置对齐属性,true / false

android : layout_alignParentTop

android : layout_alignParentBottom

android : layout_alignParentLeft

android : layout_alignParentRight

      所有加入relative layoutView默认放置在左上角

Android开发笔记(2)——ViewGroup

    2)  居中显示

android : centerHorizontal = “ true”

android : centerVertical = “true”

        结合其他属性,即可确定以上8个红星位置

    3)   View ID命名

锚定位置:无论其他元素如何变化,保持固定位置的View,相对于Child View设置,需要对每个View进行命名(设置ID)

    定义(第一次使用) android : id = “@ + id / ben_text_view”

      重复使用:@ id / ben_text_view

    4)  相对于Child View

android : layout_toLeftof = “@ id / ben_text_view”

android : layout_toRightof

android : layout_above

android : layout_below


  • Padding & Margin

    1)    两者区别

      a)      PaddingTextView处理,强行扩大原面积

      b)      MarginParent ViewGroup处理,保持原View大小,向外设置“禁飞区

Android开发笔记(2)——ViewGroup

    2)    属性设置

      四周 android : padding / android : margin

      单独(进入单独设置后,为设置参数默认为0)

android : paddingLeft / Right / Top / Bottom

android : marginLeft / Right / Top / Bottom


 

三、Android Studio安装 & 使用

    1)  Android Studio 是特定为开发Android apps应用的平台,需要先安装Java开发工具包(Java Development Kit

    2)  Android Project

    Domain——填写公司域名或者个人域名

    Package name —— 倒置“Domain + appname ”,是识别这个app的唯一标识

    Android版本——不同版本以糖果甜点来命名

    低版本可兼容高版本,高版本不支持低版本平台,例如采用最新的Marshmallow,只能保证使用最新版本的4.7%用户下载

       常采用 IcecreamSandwich,保证97.4%用户可以下载

Android开发笔记(2)——ViewGroup

    3)  实机演练:Android Phone打开设置,点击About mobile7次可打开Developer Mode

      ——如果是WINDOWS,需要下载OEM USB Drivers

    4)  电脑模拟:使用Android Emulator

      ——WINDOW 使用Virtual Devices ,需要系统支持Virtual Technology,并在BIOS中打开


l  生日贺卡实践演练

Android Studio视图配置

Android开发笔记(2)——ViewGroup

程序设计流程

Android开发笔记(2)——ViewGroup

Android Studio视图配置

Android开发笔记(2)——ViewGroup


申明:

1、本笔记为文字及图片均为个人原创,请勿转载

2、Android开发课程于2017年4年参与GoogleDeveloper进行学习,

笔记原版http://www.studyjamscn.com/thread-19454-1-1.html

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,502
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,916
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,749
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,506
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,144
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,307