Layout管理器(一般称“layouts”)是ViewGroup的扩展,被设计用来控制子控件在屏幕上的位置。Layouts能相互嵌套,通过Layout管理器的结合,你可以创建任意复杂的界面。
Android SDK包含一些简单的Layout,帮助你构建UI。选择layout间正确的结合来使界面易于理解和使用就取决于你咯。
下面的列表包含了一些更通用的layout类:
❑ FrameLayout
最简单的layout管理器,FrameLayout简单地将每一个View显示在左上角。增加多个子View时,新的View位于先前的上方,并且还遮盖先前的View。
❑ LinearLayout
LinearLayout用来沿着某一个直线方向增加子View,包括垂直的和水平的。垂直的layout每一行有一个孩子;而水平的layout只有一行。LinearLayout可以为每个子View指定“weight”,来控制在可获得的空间里每个子View的相对大小。
❑ RelativeLayout
使用RelativeLayout,你可以定义每个子View相对于其它的View或屏幕边界的位置。
❑ TableLayout
TableLayout允许你按照网格的行列来放置View。每格可以占据多个行和列,并且列可以设定为缩小或增长。
❑ AbsoluteLayout
在AbsoluteLayout里,每个子View的位置以绝对坐标进行定义。使用这个类,你可以为组件安排最精确的布局,但是有代价的。与之前的管理器比较而言,以绝对的坐标来定义layout意味着你的layout不能为不同的屏幕分辨率和方向进行动态调整。
Android文档详细的描述了每个layout的特性和属性,所以不在这里重复说明,我建议你可以参见:
http://code.google.com/android/devel/ui/layout.html.
在这章的后面,你会学习到如何通过扩展这些layout类来创建组合的控件(widget由一些互相联系的View组成)。
分享到:
相关推荐
Android-Layouts part
android 窗口布局 layouts 下的各种控件 RelativeLayout gridLayout linerLayout frameLayout
Views and Layouts Starting the Yamba Project The StatusActivity Layout The StatusActivity Java Class Logging Messages in Android Threading in Android Other UI Events Alternative Resources Summary ...
Create layouts with Android’s UI controls, graphical services, and pop-up mechanisms Build location-aware services on Google Maps and OpenStreetMap Control aspects of Android’s music, video, and ...
Construction of complex layouts on Android, major layouts available on the platform, as nest them to permit more complex graphical structures are used and how to extend them to give more ...
Google 官方发布视频
Introducing Android Views and Layouts 177 The Android View 177 The Android Controls 177 The Android Layout 178 Displaying Text to Users with TextView 179 Configuring Layout and Sizing 179 Creating ...
Get started in creating marketable apps for the burgeoning Android market. Begin your journey by learning the essentials of programming for phones and tables that are built around Google's wildly-...
Creating User Interfaces with Layouts and Widgets Chapter 10. Using Fragment Arguments Chapter 11. Using ViewPager Chapter 12. Dialogs Chapter 13. The Toolbar Chapter 14. SQLite Databases Chapter 15....
Anroid的Tabbed layouts 开发模板,亲自调试通过,可以基本此模板用Csharp进行Android软件开发
单击Graphical Layout标签,单击Layouts导航条,从中选择LinearLayout(vertical)组件图标,拖曳至 右边。如图2-2。 图2-2 (5) 添加控件 将Form Widgets等控件列表中的控件拖曳到可视设计窗口中。分别往窗体中添加3...
convert your android XML layouts into PDF document, works on all versions of Android. Dependencies pdfjet How to use Option 1: Simply fork or download the project, you can also download and create ....
Chapter 8: Designing Layouts Chapter 9: Currencies Lab: Part 1 Chapter 10: Currencies Lab: Part 2 Chapter 11: Testing and Analyzing Chapter 12: Debugging Chapter 13: Gradle Chapter 14: More SDK Tools ...
:star: Cropped layouts with percentage for Android Requirements Android 4.0.3 (API Level 15) or later Getting Started Please type it in your build.gradle file. repositories { jcenter() } ...
浮动布局android Android平台的浮动布局演示版示例项目建立步骤1.将JitPack存储库添加到您的构建文件中allprojects { repositories { maven { url "https://jitpack.io" } }}步骤2.添加依赖项dependencies { ...
Chapter 1: Layouts and Views Chapter 2: User Interaction Recipes Chapter 3: Communications and Networking Chapter 4: Interacting with Device Hardware and Media Chapter 5: Persisting Data Chapter 6: ...
Organizing user interface layouts and views Managing user-initiated events such as touches and gestures Recording and playing audio and video Using hardware APIs available on Android devices ...
Easy font usage in your Android XML layouts. This is a fork of Lisa Wray's fontbinding. Based on Data Binding Written in Kotlin Automatic initialization Automatic font caching Homogeneous android:...
Introducing Layouts To-Do List Example Introducing Fragments The Android Widget Toolbox Creating New Views Introducing Adapters Chapter 5: Intents and Broadcast Receivers Introducing Intents Creating ...
Intents, Services, Broadcast Receivers, and Content Providers Build basic Android user interfaces, and learn about Views and Layouts Create a Service to update data in your example application Learn ...