`
presses
  • 浏览: 115709 次
  • 性别: Icon_minigender_1
  • 来自: 中山
社区版块
存档分类
最新评论

declaring layout

阅读更多
一、android提借了两种方式去声明布局。一种是用xml标签方式。另一种是编程方式动态设置元素和布局。你可以用xml布局UI的默认界面,然后再用编程方式在运行时改变元素和布局。 二、布局的xml标签及属性跟java代码的类名及属性通常是对应的关系。但也有例外的情况。 三、每一个布局文件必需有一个根元素,根元素可以是view或viewgroup。然后在根元素下再添加其它元素。 四、布局文件要放在项目的res/layout/文件夹下,并以.xml为扩展名,这样文件就会自动被编译。 五、app被编译时,xml布局文件会被编译成一个view资源文件。如果要使用它,可以在Activity.onCreate()方法中调用它。例如:setContentView(R.layout.XXXX)。 六、ID:wedgit都有一个id属性。ID的格式为@+id/XXX。这样命名ID后,你可以在java代码中使用R.id.XXX引用该元素ID。例如你使用@+id/myElement后,你在java程序中可以使用this.findViewById(R.id.myElement)引用该元素。 七、Layout Parameters:每一个ViewGroup都会实现一个ViewGroup.LayoutParams接口,用于设置位置和寸尺。 八、layout position:view的几何图型是一个长方式。寸尺的单位为像素。一个view的位置一般被描述为一对数字(左、上)及两个尺寸(长、宽)。你可以通过getLeft、getTop方法获取一个元素的位置。得到的数字结果是相对于它的父元素的。 九、size、padding、margins:size被表达为width和height。一个view包括两对尺寸。一对为measuredWidth、measureHeight。它表示父节点要留给它的宽和长。另一对为width、height。它表示view的实际(可视)大小。view不支持margin。
0
0
分享到:
评论

相关推荐

    Advanced MFC Programming

    Declaring New Member Variable Creating New Tool Bar Command Message Mapping 1.2. Imitating the Behavior of Radio Buttons Radio Button & Check Box Sample 1.3. Check Box Implementation Using Boolean ...

    Manning.Spring.in.Action.4th.Edition.2014.11.epub

    6.3. Defining a layout with Apache Tiles views 6.3.1. Configuring a Tiles view resolver 6.4. Working with Thymeleaf 6.4.1. Configuring a Thymeleaf view resolver 6.4.2. Defining Thymeleaf templates 6.5...

    leetcodepushfront-Front-End-Engineer:该存储库将与DataStructures存储库并行处理

    Declaring doctypes 9/20 Accessibility concerns CSS Day Topic 9/23 Layout - place in two vs three columns 9/26 Responsive Design 9/29 Adapative Design 10/1 Specificity JavaScript Day Topic 10/4 ...

    Troubleshooting.Xcode.14842156

    Centering views horizontally with Auto Layout Chapter 44. Elements grayed out on Storyboard after copying Chapter 45. Debugging Core Data Chapter 46. "The package does not contain an Info.plist" ...

    Troubleshooting.Xcode.1484215613

    Centering views horizontally with Auto Layout Chapter 44. Elements grayed out on Storyboard after copying Chapter 45. Debugging Core Data Chapter 46. "The package does not contain an Info.plist" ...

    The Art of Assembly Language Programming

    Memory Layout and Access 4.0 - Chapter Overview 4.1 - The 80x86 CPUs:A Programmer's View 4.1.1 - 8086 General Purpose Registers 4.1.2 - 8086 Segment Registers 4.1.3 - 8086 Special ...

    CSharp 3.0 With the .NET Framework 3.5 Unleashed(english)

    16 Declaring Attributes and Examining Code with Reflection 368 Using Attributes 369 Using Attribute Parameters 371 Attribute Targets 373 Creating Your Own Attributes 374 Using Reflection ...

    Developing Flex Applications 910p dda_doc88_cracker.zip

    This package contains 3 kid: 1. a book Developing Flex Applications 2. a web page viewer for doc88 ebt ... CONTENTS PART I: Presenting Flex CHAPTER 1: Introducing Flex....About Flex....

    ZendFramework中文文档

    14.5.1. Declaring Filter and Validator Rules 14.5.2. Creating the Filter and Validator Processor 14.5.3. Retrieving Validated Fields and other Reports 14.5.3.1. Querying if the input is valid 14.5...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Table of Contents Header Files The #define Guard Header File Dependencies Inline Functions The -inl.h Files Function Parameter Ordering Names and Order of Includes Scoping Namespaces Nested Classes ...

    VB.NET Developer's Guide(4574).pdf

    Declaring an Array 188 Multidimensional Arrays 189 Dynamic Arrays 191 Functions 192 Object Oriented Programming 196 Inheritance 196 Polymorphism 197 Encapsulation 197 Classes 198 Adding ...

    Basic4Android 初學者指南 英文版

    1 Getting started........................................................................................................................7 1.1 Installing Basic4Android and Android SDK ...................

Global site tag (gtag.js) - Google Analytics