Android培训班(44)

<!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } -->

layout-landlayout-port目录主要用来保存应用程序的界面布局的文件。layout-landandroid应用程序界面横屏显示的布局设置;layout-portandroid应用程序界面竖屏显示的布局设置。由于这两种显示,导致应用程序的显示比例不一样,因此应用程序需要根据不同的比例进行重新布局,不能简单地进行缩放显示,否则就显得界面不好使用,屏幕的空间没有最大化地利用。本来手机的屏幕就是很小的一个显示屏,如果不尽量使用,肯定就不满足用户的需求。当然两种显示的方式,也可以最大化共用相同的图片和字符串等资源。

 

layout-land的目录下面,有如下的两个文件:

main.xmlhistory_item.xml

接着来查看main.xml,可以看到这个文件的内容如下:

<?xml version="1.0" encoding="utf-8"?>

这行说明XML的版本,编码的格式。

 

<!--

/*

* Copyright (C) 2008, The Android Open Source Project

*

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#ff000000">

android的应用程序界面里,主要有五种布局方式:帧布局(FrameLayout),线性布局(LinearLayout),绝对布局(AbsoluteLayout),相对布局(RelativeLayout),表格布局(TableLayout)。

在这里主要使用线性布局(LinearLayout),那么这种布局有什么样的特点呢?顾名思义,就是对界面元素进行线性的排列,比如一行有10个文本显示框,如果进行线性布局,并且是水平方向布局,那么就可以排成一行,如果显示屏不够大,后面的元素就显示不了。如果是垂直方向布局,就会每一行一个文本框的方式显示,显示为10行。在线性布局里,如果不指明布局方式,默认为水平方向排列。当然线性布局也可以嵌套显示多行子元素,但这样维护起来比较困难,应使用相对布局(RelativeLayout)来实现,这样更加方便。

转载于:https://www.cnblogs.com/ajuanabc/archive/2011/04/10/2463255.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值