zoukankan      html  css  js  c++  java
  • Android五大布局详解——FrameLayout(帧布局)

    FrameLayout

    这个布局相对前面两节介绍的布局就简单了很多,因此它的应用场景也就特别的少。这种布局没有方便的定位方式,所有的控件都会默认摆放在布局的左上角。新建UILayoutTestThree工程,修改activity_main.xml的代码:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <TextView
            android:id="@+id/text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="This is FrameLayout"
            />
    
        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="FrameLayout"
            />
    
    </FrameLayout>
    

    运行程序,效果如图:

    可以看到两个控件都集中在了左上角的位置。因为TextView控件在Button控件之前添加,因此Button在TextView上面。之前我们学习了layout_gravity属性来指定控件在布局中的对齐方式,这里也同样适用。修改activity_main.xml中的代码:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <TextView
            android:id="@+id/text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:text="This is FrameLayout ........."
            />
    
        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:text="FrameLayout"
            />
    
    </FrameLayout>
    

  • 相关阅读:
    AOP实践--利用MVC5 Filter实现登录状态判断
    InstallShield12的安装破解方法
    phantomjs + python 打造一个微信机器人
    ASP.NET MVC4中@model使用多个类型实例的方法
    ssi技术
    ubuntu下面如何切换virtual_box的鼠标
    叫醒你的是闹钟,还是梦想?
    在linux命令行中直接执行php命令
    如何修改mysql默认的数据库密码
    【转】想要成功,请记住!
  • 原文地址:https://www.cnblogs.com/AleiCui/p/11832834.html
Copyright © 2011-2022 走看看