• 2-26安卓自学


      今天学习FrameLayout(帧布局)

    FrameLayout(帧布局)可以说是六大布局中最为简单的一个布局,这个布局直接在屏幕上开辟出一块空白的区域,当我们往里面添加控件的时候,会默认把他们放到这块区域的左上角,而这种布局方式却没有任何的定位方式,所以它应用的场景并不多;帧布局的大小由控件中最大的子控件决定,如果控件的大小一样大的话,那么同一时刻就只能看到最上面的那个组件!后续添加的控件会覆盖前一个!虽然默认会将控件放置在左上角,但是我们也可以通过layout_gravity属性,指定到其他的位置

    常用属性

    FrameLayout的属性很少就两个,但是在说之前我们先介绍一个东西:

    前景图像:永远处于帧布局最上面,直接面对用户的图像,就是不会被覆盖的图片。

    两个属性:

    android:foreground:*设置改帧布局容器的前景图像

    android:foregroundGravity:设置前景图像显示的位置

    样例代码如下:

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    
        xmlns:tools="http://schemas.android.com/tools"    
        android:id="@+id/FrameLayout1"    
        android:layout_width="match_parent"    
        android:layout_height="match_parent"    
        tools:context=".MainActivity"     
        android:foreground="@drawable/logo"    
        android:foregroundGravity="right|bottom">    
        
        <TextView    
            android:layout_width="200dp"    
            android:layout_height="200dp"    
            android:background="#FF6143" />    
        <TextView    
            android:layout_width="150dp"    
            android:layout_height="150dp"    
            android:background="#7BFE00" />    
         <TextView    
            android:layout_width="100dp"    
            android:layout_height="100dp"    
            android:background="#FFFF00" />    
            
    </FrameLayout>
  • 相关阅读:
    python中的BeautifulSoup使用小结
    python数字前自动补零
    python列表中的所有值转换为字符串,以及列表拼接成一个字符串
    python爬虫requests过程中添加headers
    django+mysql简单总结
    python数字转换为字符串的两种方式
    python自带的IDLE如何清屏
    django模板中的自定义过滤器
    python中的requests使用小结
    在非UI线程中自制Dispatcher
  • 原文地址:https://www.cnblogs.com/ruangongwangxiansheng/p/14906295.html
Copyright © 2020-2023  润新知