源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android布局之FrameLayout帧布局

  • 时间:2020-11-11 01:55 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android布局之FrameLayout帧布局
[b]前言[/b] 作为android六大布局中最为简单的布局之一,该布局直接在屏幕上开辟出了一块空白区域, 当我们往里面添加组件的时候,所有的组件都会放置于这块区域的左上角; 帧布局的大小由子控件中最大的子控件决定,如果都组件都一样大的话,同一时刻就只能能看到最上面的那个组件了! 当然我们也可以为组件添加layout_gravity属性,从而制定组件的对其方式 帧布局在游戏开发方面用的比较多,等下后面会给大家演示一下比较有意思的两个实例 [img]http://files.jb51.net/file_images/article/201512/20151231103243165.png?2015113110330[/img] (-)帧布局简介 帧布局容器为每个加入的其中的组件创建一个空白的区域称为一帧每个子组件占据一帧,这些帧都会根据gravity的属性执行自动对齐 (二)常用属性: android:foreground:设置该帧布局容器的前景图像 android:foregroundGravity:设置前景图像显示的位置 (三)使用
<?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">
 <FrameLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  >
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center"
   android:width="300dp"
   android:height="300dp"
   android:background="#f00"/>
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center"
   android:width="200dp"
   android:height="200dp"
   android:background="#0f0"/>
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center"
   android:width="100dp"
   android:height="100dp"
   android:background="#00f"/>
 </FrameLayout>
</LinearLayout>
以上内容给大家介绍了Android布局之FrameLayout帧布局,希望大家喜欢。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部