zoukankan      html  css  js  c++  java
  • Android中FrameLayout总结

    今天在学习实现墨迹天气那样的拖动效果时,看到用的是重写FrameLayout

    FrameLayout布局是最简单的布局方式,所有添加到这个布局中的视图都是以层叠的方式显示。第一个添加到布局中视图显示在最底层,最后一个被放在最顶层。上一层的视图会覆盖下一层的视图,因此该布局类似于堆栈布局。注意点:a.默认对其方式是左上角对齐。b.若要设置子视图的位置,要设置layout_gravity属性值。

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <FrameLayout
     3     xmlns:android="http://schemas.android.com/apk/res/android"
     4     android:layout_width="fill_parent"
     5     android:layout_height="fill_parent"
     6     android:background="#897753"
     7     >
     8     <ImageView 
     9         android:id="@+id/image1"
    10         android:layout_width="fill_parent"
    11         android:layout_height="fill_parent"
    12         android:visibility="invisible"
    13         android:src="@drawable/sky"/>
    14     <ImageView 
    15         android:id="@+id/image2"
    16         android:visibility="invisible"
    17         android:layout_width="fill_parent"
    18         android:layout_height="fill_parent"
    19         android:src="@drawable/cloud"/>
    20     <ImageView 
    21         android:id="@+id/image3"
    22         android:visibility="invisible"
    23         android:layout_width="fill_parent"
    24         android:layout_height="fill_parent"
    25         android:src="@drawable/sun"/>
    26 
    27 </FrameLayout>

    其中,image1、image2、image3都是在同一块空间的。可以说它们是重叠着的,界面显示的是最近用的那一个。

  • 相关阅读:
    web架构
    网站开发的学习交流 系统架构 负载均衡
    数据库连接
    OpenCV4【12】边缘检测
    python基础_格式化输出(%用法和format用法)
    Python之telnetlib模块
    根据文字或图片来生成用于Banner输出的字符画
    Python3 range() 函数用法
    Python psutil cpu_percent调用说明
    @staticmethod和@classmethod的用法
  • 原文地址:https://www.cnblogs.com/baorantHome/p/5853263.html
Copyright © 2011-2022 走看看