zoukankan      html  css  js  c++  java
  • Android UI布局之FrameLayout

    一个FrameLayout对象就好比一块屏幕上提前预定好的空白区域。然后能够填充一些元素到里边。例如说一张图片等。须要注意的是,全部的元素都被放置在FrameLayout区域最左边上的区域。并且无法为这些元素指定一个确切的位置。假设一个FrameLayout里边有多个子元素。那么后边的子元素的显示会重叠在前一个元素上。

    实例:LayoutDemo
    执行效果:


    代码清单:
    布局文件:frame_layout.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" > <ImageView android:id="@+id/photo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg" /> </FrameLayout>


    android:id      定义组件的id,在应用程序中。我们通过这个id就能够訪问到定义的这个元素。
    android:layout_width="match_parent" 和android:layout_height="match_parent"     表示FrameLayout布局能够在x轴方向和y轴方向填充满父容器的空间。
    android:layout_width="wrap_content" 和android:layout_height+"wrap_content"     表示ImageView元素的长和宽仅仅须要将bg.jpg包裹起来就可以,并不须要填充满父容器。



    Java源码文件:FrameLayoutActivity.java

    package com.rainsong.layoutdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class FrameLayoutActivity extends Activity
    {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.frame_layout);
        }
    }
    

  • 相关阅读:
    Qt Creater更改默认构建目录
    QT-无法定位程序输入点解决方案
    Qt qmake报错(TypeError: Property 'asciify' of object Core::Internal::UtilsJsExtension)
    python学习--交互式图形编程实例二
    python学习--交互式图形编程实例一
    python学习--面向对象程序设计实例
    python学习--面向过程程序设计实例
    python学习--程序设计方法实例一
    python学习--字典操作实例二
    python学习--文档
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5245561.html
Copyright © 2011-2022 走看看