zoukankan      html  css  js  c++  java
  • android常用布局

    布局

        组件按照布局的要求依次排列,就组成了用户所看见的界面。Android的五大布局分别是LinearLayout(线性布局)、FrameLayout(单帧布局)、RelativeLayout(相对布局)、AbsoluteLayout(绝对布局)和TableLayout(表格布局)。

    一、LinearLayout(线性布局)、FrameLayout(单帧布局)

     1 <?xml version="1.0" encoding="utf-8"?>
    2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3 android:orientation="vertical"
    4 android:layout_width="fill_parent"
    5 android:layout_height="fill_parent"
    6 >
    7 <!--
    8 首先是线性布局这里面每一个元素跟在另一个元素的后面。可参考下列设置!主要是android:layout_weight="1"管用了
    9 -->
    10 <LinearLayout
    11 android:orientation="horizontal"
    12 android:layout_width="fill_parent"
    13 android:layout_height="wrap_content"
    14 >
    15 <TextView
    16 android:layout_width="fill_parent"
    17 android:layout_height="wrap_content"
    18 android:layout_weight="1"
    19 android:background="#EFDAB8"
    20 />
    21 <TextView
    22 android:layout_width="fill_parent"
    23 android:layout_height="wrap_content"
    24 android:layout_weight="1"
    25 android:background="#FBAFF5"
    26 />
    27 </LinearLayout>
    28 <LinearLayout
    29 android:orientation="horizontal"
    30 android:layout_width="fill_parent"
    31 android:layout_height="wrap_content"
    32 >
    33 <TextView
    34 android:layout_width="fill_parent"
    35 android:layout_height="wrap_content"
    36 android:layout_weight="2"
    37 android:background="#EFDAB8"
    38 />
    39 <TextView
    40 android:layout_width="fill_parent"
    41 android:layout_height="wrap_content"
    42 android:layout_weight="1"
    43 android:background="#FBAFF5"
    44 />
    45 </LinearLayout>
    46 <!--
    47 FrameLayout布局就是单帧布局 FrameLayout是五大布局中最简单的一个布局,
    48 在这个布局中,整个界面被当成一块空白备用区域,所有的子元素都不能被指定放置
    49 的位置,它们统统放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元
    50 素之上,将前面的子元素部分和全部遮挡。例子如下
    51 -->
    52 <FrameLayout
    53 android:layout_width="fill_parent"
    54 android:layout_height="fill_parent"
    55 android:background="#525252"
    56 >
    57 <TextView
    58 android:layout_width="fill_parent"
    59 android:layout_height="fill_parent"
    60 android:background="#644121"
    61 />
    62 <TextView
    63 android:layout_width="wrap_content"
    64 android:layout_height="wrap_content"
    65 android:background="#B5D556"
    66 android:text="你好我的世界!"
    67 android:textSize="24sp"
    68 android:textColor="#F56700"
    69 />
    70 </FrameLayout>
    71 </LinearLayout>


  • 相关阅读:
    最小生成树(二)Prim算法
    红黑树
    最短路径:Dijstra(迪杰斯特拉)算法
    30岁的程序员,未来之路-写于疫情笼罩下的北京-中国-地球
    Spring Cloud 系列之Hystrix、Ribbon、Feign 源码剖析(一)引子
    A left join B B表有多条记录,max(create_time)取最新一条
    最新idea破解码,亲测可用
    Spring Cloud Gateway简单使用
    开源的C#实现WebSocket协议客户端和服务器websocket-sharp组件解析
    简单易用的.NET免费开源RabbitMQ操作组件EasyNetQ解析
  • 原文地址:https://www.cnblogs.com/Acmen/p/2174626.html
Copyright © 2011-2022 走看看