现在的位置: 首页 > 综合 > 正文

[Android] 布局基础知识点

2013年06月06日 ⁄ 综合 ⁄ 共 1165字 ⁄ 字号 评论关闭

线性布局-LinearLayout


  1. 线性布局不会换行,当组件一个挨着一个排列到头之后,剩下的组件将不会被显示出来。
  1. 线性布局中最重要的两个属性

android:orientation  设置布局管理器内组件的排列方式

      水平排列:horizontal                垂直排列:vertical

                android:gravity          设置布局管理器内组件的对齐方式

                     top|bottom|left|right|center_vertical|center_horizontal|center|…

  1. Android:gravity属性中的多个属性值之间可以用竖线隔开
View Code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width
="match_parent"
    android:layout_height
="match_parent"
    android:orientation
="vertical"
    android:gravity
="center|left">

    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    

</LinearLayout>

抱歉!评论已关闭.